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

Safe HaskellNone
LanguageHaskell98

Database.Groundhog.Generic.PersistBackendHelpers

Description

This helper module contains generic versions of PersistBackend functions

Synopsis

Documentation

select :: forall conn r v c opts. (SqlDb conn, r ~ RestrictionHolder v c, PersistBackendConn conn, PersistEntity v, EntityConstr v c, HasSelectOptions opts conn r) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> (opts -> RenderS conn r) -> Utf8 -> opts -> Action conn [v] Source #

selectAll :: forall conn v. (PersistBackendConn conn, PersistEntity v) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> Action conn [(AutoKey v, v)] Source #

selectStream :: forall conn r v c opts. (SqlDb conn, r ~ RestrictionHolder v c, PersistBackendConn conn, PersistEntity v, EntityConstr v c, HasSelectOptions opts conn r) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> (opts -> RenderS conn r) -> Utf8 -> opts -> Action conn (RowStream v) Source #

selectAllStream :: forall conn v. (PersistBackendConn conn, PersistEntity v) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> Action conn (RowStream (AutoKey v, v)) Source #

It may call the passed function multiple times

getBy Source #

Arguments

:: (PersistBackendConn conn, PersistEntity v, IsUniqueKey (Key v (Unique u))) 
=> RenderConfig 
-> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue]))

function to run query

-> Key v (Unique u) 
-> Action conn (Maybe v) 

project :: forall conn r v c p opts a'. (SqlDb conn, r ~ RestrictionHolder v c, PersistBackendConn conn, PersistEntity v, EntityConstr v c, Projection p a', ProjectionDb p conn, ProjectionRestriction p r, HasSelectOptions opts conn r) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> (opts -> RenderS conn r) -> Utf8 -> p -> opts -> Action conn [a'] Source #

projectStream :: forall conn r v c p opts a'. (SqlDb conn, r ~ RestrictionHolder v c, PersistBackendConn conn, PersistEntity v, EntityConstr v c, Projection p a', ProjectionDb p conn, ProjectionRestriction p r, HasSelectOptions opts conn r) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> (opts -> RenderS conn r) -> Utf8 -> p -> opts -> Action conn (RowStream a') Source #

count :: forall conn r v c. (SqlDb conn, r ~ RestrictionHolder v c, PersistBackendConn conn, PersistEntity v, EntityConstr v c) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> Cond conn r -> Action conn Int Source #

replace :: forall conn r v. (PersistBackendConn conn, PersistEntity v, PrimitivePersistField (Key v BackendSpecific)) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> (Utf8 -> [PersistValue] -> Action conn ()) -> (Bool -> Utf8 -> ConstructorDef -> [PersistValue] -> RenderS conn r) -> Key v BackendSpecific -> v -> Action conn () Source #

replaceBy Source #

Arguments

:: (PersistBackendConn conn, PersistEntity v, IsUniqueKey (Key v (Unique u))) 
=> RenderConfig 
-> (Utf8 -> [PersistValue] -> Action conn ())

function to execute query

-> u (UniqueMarker v) 
-> v 
-> Action conn () 

update :: forall conn r v c. (SqlDb conn, r ~ RestrictionHolder v c, PersistBackendConn conn, PersistEntity v, EntityConstr v c) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn ()) -> [Update conn r] -> Cond conn r -> Action conn () Source #

delete :: forall conn r v c. (SqlDb conn, r ~ RestrictionHolder v c, PersistBackendConn conn, PersistEntity v, EntityConstr v c) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn ()) -> Cond conn r -> Action conn () Source #

deleteAll :: forall conn v. (PersistBackendConn conn, PersistEntity v) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn ()) -> v -> Action conn () Source #

insertByAll Source #

Arguments

:: (PersistBackendConn conn, PersistEntity v) 
=> RenderConfig 
-> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue]))

function to run query

-> Bool

allow multiple duplication of uniques with nulls

-> v 
-> Action conn (Either (AutoKey v) (AutoKey v)) 

countAll :: forall conn v. (PersistBackendConn conn, PersistEntity v) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> v -> Action conn Int Source #

insertBy :: forall conn v u. (PersistBackendConn conn, PersistEntity v, IsUniqueKey (Key v (Unique u))) => RenderConfig -> (Utf8 -> [PersistValue] -> Action conn (RowStream [PersistValue])) -> Bool -> u (UniqueMarker v) -> v -> Action conn (Either (AutoKey v) (AutoKey v)) Source #