Extra persistent graph classes & instances for ticket graph
This commit is contained in:
parent
810a329a76
commit
6220c78f74
2 changed files with 25 additions and 5 deletions
|
@ -15,6 +15,8 @@
|
|||
|
||||
module Database.Persist.Local.Class.PersistEntityGraph
|
||||
( PersistEntityGraph (..)
|
||||
, PersistEntityGraphSelect (..)
|
||||
, PersistEntityGraphNumbered (..)
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -23,8 +25,17 @@ import Prelude
|
|||
import Database.Persist
|
||||
|
||||
class (PersistEntity n, PersistEntity e) => PersistEntityGraph n e where
|
||||
sourceParam :: e -> Key n
|
||||
sourceField :: EntityField e (Key n)
|
||||
destParam :: e -> Key n
|
||||
destField :: EntityField e (Key n)
|
||||
|
||||
class PersistEntityGraph n e => PersistEntityGraphSelect n e where
|
||||
type PersistEntityGraphSelector n e
|
||||
sourceParam :: e -> Key n
|
||||
sourceField :: EntityField e (Key n)
|
||||
destParam :: e -> Key n
|
||||
destField :: EntityField e (Key n)
|
||||
selectorParam :: n -> PersistEntityGraphSelector n e
|
||||
selectorField :: EntityField n (PersistEntityGraphSelector n e)
|
||||
|
||||
class PersistEntityGraphSelect n e => PersistEntityGraphNumbered n e where
|
||||
numberParam :: n -> Int
|
||||
numberField :: EntityField n Int
|
||||
uniqueNode :: PersistEntityGraphSelector n e -> Int -> Unique n
|
||||
|
|
|
@ -56,8 +56,17 @@ instance Hashable ProjectRoleId where
|
|||
hash = hash . fromSqlKey
|
||||
|
||||
instance PersistEntityGraph Ticket TicketDependency where
|
||||
type PersistEntityGraphSelector Ticket TicketDependency = ProjectId
|
||||
sourceParam = ticketDependencyParent
|
||||
sourceField = TicketDependencyParent
|
||||
destParam = ticketDependencyChild
|
||||
destField = TicketDependencyChild
|
||||
|
||||
instance PersistEntityGraphSelect Ticket TicketDependency where
|
||||
type PersistEntityGraphSelector Ticket TicketDependency = ProjectId
|
||||
selectorParam = ticketProject
|
||||
selectorField = TicketProject
|
||||
|
||||
instance PersistEntityGraphNumbered Ticket TicketDependency where
|
||||
numberParam = ticketNumber
|
||||
numberField = TicketNumber
|
||||
uniqueNode = UniqueTicket
|
||||
|
|
Loading…
Reference in a new issue