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

Safe HaskellNone

Database.Persist.Query

Contents

Synopsis

Documentation

class PersistStore backend m => PersistQuery backend m whereSource

Methods

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

Update individual fields on a specific record.

updateGet :: PersistEntity val => Key backend val -> [Update val] -> backend m valSource

Update individual fields on a specific record, and retrieve the updated value from the database.

Note that this function will throw an exception if the given key is not found in the database.

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

Update individual fields on any record matching the given criterion.

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

Delete all records matching the given criterion.

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

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

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

get just the first record for the criterion

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

Get the Keys of all records matching the given criterion.

count :: PersistEntity val => [Filter val] -> backend m IntSource

The total number of records fulfilling the given criterion.

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

Call selectSource but return the result as a list.

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

Call selectKeys but return the result as a list.

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

data SelectOpt v Source

Constructors

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

data Filter v Source

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 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