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

Safe HaskellNone
LanguageHaskell98

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, 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) -> (opts -> RenderS db r) -> 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

getBy Source

Arguments

:: (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, db ~ PhantomDb m, r ~ RestrictionHolder v c, PersistBackend m, PersistEntity v, EntityConstr v c, Projection p a', ProjectionDb p db, ProjectionRestriction p r, HasSelectOptions opts db r) => RenderConfig -> (forall a. Utf8 -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> (opts -> RenderS db r) -> Utf8 -> p -> opts -> m [a'] Source

count :: forall m db r v c. (SqlDb 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 Int Source

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

replaceBy Source

Arguments

:: (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, 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, 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

insertByAll Source

Arguments

:: (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 Int Source

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