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

Safe HaskellSafe-Infered

Database.Persist.Query

Contents

Synopsis

Documentation

class PersistStore b m => PersistQuery b m where

Methods

update :: PersistEntity val => Key b val -> [Update val] -> b m ()

Update individual fields on a specific record.

updateWhere :: PersistEntity val => [Filter val] -> [Update val] -> b m ()

Update individual fields on any record matching the given criterion.

deleteWhere :: PersistEntity val => [Filter val] -> b m ()

Delete all records matching the given criterion.

selectSource :: (PersistEntity val, PersistEntityBackend val ~ b) => [Filter val] -> [SelectOpt val] -> Source (ResourceT (b m)) (Entity val)

Get all records matching the given criterion in the specified order. Returns also the identifiers.

selectFirst :: (PersistEntity val, PersistEntityBackend val ~ b) => [Filter val] -> [SelectOpt val] -> b m (Maybe (Entity val))

get just the first record for the criterion

selectKeys :: PersistEntity val => [Filter val] -> Source (ResourceT (b m)) (Key b val)

Get the Keys of all records matching the given criterion.

count :: PersistEntity val => [Filter val] -> b m Int

The total number of records fulfilling the given criterion.

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

Call select but return the result as a list.

deleteCascadeWhere :: (DeleteCascade a b m, PersistQuery b m) => [Filter a] -> b m ()

data SelectOpt v

Constructors

forall typ . Asc (EntityField v typ) 
forall typ . Desc (EntityField v typ) 
OffsetBy Int 
LimitTo Int 

data Filter v

Filters which are available for select, updateWhere and deleteWhere. Each filter constructor specifies the field being filtered on, the type of comparison applied (equals, not equals, etc) and the argument for the comparison.

Constructors

forall typ . PersistField typ => Filter 
FilterAnd [Filter v]

convenient for internal use, not needed for the API

FilterOr [Filter v] 

query combinators

(=.), (/=.), (*=.), (-=.), (+=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update v

assign a field a value

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

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

In

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

the OR of two lists of filters