persistent-1.1.5.1: Type-safe, multi-backend data serialization.

Safe Haskell | None

Database.Persist.Query.Join

Contents

- Typeclass
- One-to-many relation

Synopsis

- class PersistQuery m => RunJoin a m where
  - type Result a
  - runJoin :: a -> m (Result a)
- data SelectOneMany one many = SelectOneMany {
  - somFilterOne :: [Filter one]
  - somOrderOne :: [SelectOpt one]
  - somFilterMany :: [Filter many]
  - somOrderMany :: [SelectOpt many]
  - somFilterKeys :: [Key one] -> Filter many
  - somGetKey :: many -> Key one
  - somIncludeNoMatch :: Bool
  }
- selectOneMany :: ([Key one] -> Filter many) -> (many -> Key one) -> SelectOneMany one many

# Typeclass

class PersistQuery m => RunJoin a m where

Associated Types

type Result a

Methods

runJoin :: a -> m (Result a)

Instances

(PersistEntity one, PersistEntity many, Ord (Key one), PersistQuery monad, ~ * (PersistMonadBackend monad) (PersistEntityBackend one), ~ * (PersistEntityBackend one) (PersistEntityBackend many)) => RunJoin (SelectOneMany one many) monad |

# One-to-many relation

data SelectOneMany one many

Constructors

SelectOneMany |
Fields somFilterOne :: [Filter one] somOrderOne :: [SelectOpt one] somFilterMany :: [Filter many] somOrderMany :: [SelectOpt many] somFilterKeys :: [Key one] -> Filter many somGetKey :: many -> Key one somIncludeNoMatch :: Bool

Instances

(PersistEntity one, PersistEntity many, Eq (Key one)) => RunJoin (SelectOneMany one many) |
(PersistEntity one, PersistEntity many, Ord (Key one), PersistQuery monad, ~ * (PersistMonadBackend monad) (PersistEntityBackend one), ~ * (PersistEntityBackend one) (PersistEntityBackend many)) => RunJoin (SelectOneMany one many) monad |

selectOneMany :: ([Key one] -> Filter many) -> (many -> Key one) -> SelectOneMany one many