groundhog-0.4.2: Type-safe datatype-database mapping library.

Safe HaskellNone

Database.Groundhog.Generic.PersistBackendHelpers

Description

This helper module contains generic versions of PersistBackend functions

Documentation

get :: forall m v. (PersistBackend m, PersistEntity v, PrimitivePersistField (Key v BackendSpecific)) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> Key v BackendSpecific -> m (Maybe v)Source

select :: forall m db r v c opts. (SqlDb db, QueryRaw db ~ Snippet db, db ~ PhantomDb m, r ~ RestrictionHolder v c, PersistBackend m, PersistEntity v, EntityConstr v c, HasSelectOptions opts db r) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> Utf8 -> opts -> m [v]Source

selectAll :: forall m v. (PersistBackend m, PersistEntity v) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> m [(AutoKey v, v)]Source

getBySource

Arguments

:: forall m v u . (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u))) 
=> RenderConfig 
-> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a)

function to run query

-> Key v (Unique u) 
-> m (Maybe v) 

project :: forall m db r v c p opts a'. (SqlDb db, QueryRaw db ~ Snippet db, db ~ PhantomDb m, r ~ RestrictionHolder v c, PersistBackend m, PersistEntity v, EntityConstr v c, Projection p db r a', HasSelectOptions opts db r) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> Utf8 -> p -> opts -> m [a']Source

count :: forall m db r v c. (SqlDb db, QueryRaw db ~ Snippet db, db ~ PhantomDb m, r ~ RestrictionHolder v c, PersistBackend m, PersistEntity v, EntityConstr v c) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> Cond db r -> m IntSource

replace :: forall m db r v. (PersistBackend m, PersistEntity v, PrimitivePersistField (Key v BackendSpecific)) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> (Utf8 -> [PersistValue] -> m ()) -> (Bool -> Utf8 -> ConstructorDef -> [PersistValue] -> RenderS db r) -> Key v BackendSpecific -> v -> m ()Source

replaceBySource

Arguments

:: forall m v u . (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u))) 
=> RenderConfig 
-> (Utf8 -> [PersistValue] -> m ())

function to execute query

-> u (UniqueMarker v) 
-> v 
-> m () 

update :: forall m db r v c. (SqlDb db, QueryRaw db ~ Snippet db, db ~ PhantomDb m, r ~ RestrictionHolder v c, PersistBackend m, PersistEntity v, EntityConstr v c) => RenderConfig -> (Utf8 -> [PersistValue] -> m ()) -> [Update db r] -> Cond db r -> m ()Source

delete :: forall m db r v c. (SqlDb db, QueryRaw db ~ Snippet db, db ~ PhantomDb m, r ~ RestrictionHolder v c, PersistBackend m, PersistEntity v, EntityConstr v c) => RenderConfig -> (Utf8 -> [PersistValue] -> m ()) -> Cond db r -> m ()Source

deleteAll :: forall m v. (PersistBackend m, PersistEntity v) => RenderConfig -> (Utf8 -> [PersistValue] -> m ()) -> v -> m ()Source

insertByAllSource

Arguments

:: forall m v . (PersistBackend m, PersistEntity v) 
=> RenderConfig 
-> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a)

function to run query

-> Bool

allow multiple duplication of uniques with nulls

-> v 
-> m (Either (AutoKey v) (AutoKey v)) 

countAll :: forall m v. (PersistBackend m, PersistEntity v) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> v -> m IntSource

insertBy :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u))) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> Bool -> u (UniqueMarker v) -> v -> m (Either (AutoKey v) (AutoKey v))Source