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

Safe HaskellNone

Database.Persist

Contents

Synopsis

Documentation

Store functions

insertBy :: (PersistEntity v, PersistStore m, PersistUnique m, PersistMonadBackend m ~ PersistEntityBackend v) => v -> m (Either (Entity v) (Key v))Source

Insert a value, checking for conflicts with any unique constraints. If a duplicate exists in the database, it is returned as Left. Otherwise, the new 'Key is returned as Right.

getJust :: (PersistStore m, PersistEntity val, Show (Key val), PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> m valSource

Same as get, but for a non-null (not Maybe) foreign key Unsafe unless your database is enforcing that the foreign key is valid

belongsTo :: (PersistStore m, PersistEntity ent1, PersistEntity ent2, PersistMonadBackend m ~ PersistEntityBackend ent2) => (ent1 -> Maybe (Key ent2)) -> ent1 -> m (Maybe ent2)Source

belongsToJust :: (PersistStore m, PersistEntity ent1, PersistEntity ent2, PersistMonadBackend m ~ PersistEntityBackend ent2) => (ent1 -> Key ent2) -> ent1 -> m ent2Source

same as belongsTo, but uses getJust and therefore is similarly unsafe

getByValue :: (PersistEntity v, PersistUnique m, PersistEntityBackend v ~ PersistMonadBackend m) => v -> m (Maybe (Entity v))Source

A modification of getBy, which takes the PersistEntity itself instead of a Unique value. Returns a value matching one of the unique keys. This function makes the most sense on entities with a single Unique constructor.

Query functions

selectList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Entity val]Source

Call selectSource but return the result as a list.

selectKeysList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Key val]Source

Call selectKeys but return the result as a list.

query combinators

(=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update vSource

assign a field a value

(+=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update vSource

assign a field by addition (+=)

(-=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update vSource

assign a field by subtraction (-=)

(*=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update vSource

assign a field by multiplication (*=)

(/=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update vSource

assign a field by division (/=)

(==.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter vSource

(!=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter vSource

(<.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter vSource

(>.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter vSource

(<=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter vSource

(>=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter vSource

(<-.) :: forall v typ. PersistField typ => EntityField v typ -> [typ] -> Filter vSource

In

(/<-.) :: forall v typ. PersistField typ => EntityField v typ -> [typ] -> Filter vSource

NotIn

(||.) :: forall v. [Filter v] -> [Filter v] -> [Filter v]Source

the OR of two lists of filters

JSON Utilities

Other utililities