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

Safe Haskell | None
Language | Haskell98

Database.Persist

Contents

- query combinators
- JSON Utilities
- Other utililities

Synopsis

- module Database.Persist.Class
- module Database.Persist.Types
- (=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update v
- (+=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update v
- (-=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update v
- (*=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update v
- (/=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Update v
- (==.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter v
- (!=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter v
- (<.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter v
- (>.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter v
- (<=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter v
- (>=.) :: forall v typ. PersistField typ => EntityField v typ -> typ -> Filter v
- (<-.) :: forall v typ. PersistField typ => EntityField v typ -> [typ] -> Filter v
- (/<-.) :: forall v typ. PersistField typ => EntityField v typ -> [typ] -> Filter v
- (||.) :: forall v. [Filter v] -> [Filter v] -> [Filter v]
- listToJSON :: [PersistValue] -> Text
- mapToJSON :: [(Text, PersistValue)] -> Text
- toJsonText :: ToJSON j => j -> Text
- getPersistMap :: PersistValue -> Either Text [(Text, PersistValue)]
- limitOffsetOrder :: PersistEntity val => [SelectOpt val] -> (Int, Int, [SelectOpt val])

# Documentation

module Database.Persist.Class

module Database.Persist.Types

# query combinators

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

assign a field a value

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

assign a field by addition (+=)

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

assign a field by subtraction (-=)

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

assign a field by multiplication (*=)

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

assign a field by division (/=)

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

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

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

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

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

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

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

In

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

NotIn

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

the OR of two lists of filters. For example: selectList([PersonAge >. 25, PersonAge 30] ||. [PersonIncome. 15000, PersonIncome <. 25000]) [] will filter records where a person's age is between (25 and 30) OR a person's income is between (15,000 and 25000). If you are looking for an &&. operator to do (A AND B AND (C OR D)) you can use the ++ operator instead as there is no &&. For example: selectList([PersonAge >. 25, PersonAge <. 30] ++ ([PersonCategory ==. 1] ||. [PersonCategory ==. 5])) [] will filter records where a person's age is between (25 and 30) AND (person's category is either 1 or 5)

# JSON Utilities

listToJSON :: [PersistValue] -> Text

mapToJSON :: [(Text, PersistValue)] -> Text

toJsonText :: ToJSON j => j -> Text

getPersistMap :: PersistValue -> Either Text [(Text, PersistValue)]

# Other utililities

limitOffsetOrder :: PersistEntity val => [SelectOpt val] -> (Int, Int, [SelectOpt val])