Safe Haskell | None |
---|---|
Language | Haskell2010 |
The persistent
library, and in particular its quasi-quoters
for entities, generate data types which do not look exactly as
plain records. This module defines some wrappers which modify
the ToSchema
and FromSchema
derivation to work with them.
Synopsis
- newtype WithEntityNestedId (ty :: Symbol) (fmap :: Mappings Symbol Symbol) a = WithEntityNestedId {
- unWithEntityNestedId :: a
- newtype WithEntityPlainId (ty :: Symbol) (fmap :: Mappings Symbol Symbol) a = WithEntityPlainId {
- unWithEntityPlainId :: a
- runDb :: MonadIO m => SqlBackend -> ReaderT SqlBackend (NoLoggingT (ResourceT IO)) a -> m a
Wrappers for use with DerivingVia
newtype WithEntityNestedId (ty :: Symbol) (fmap :: Mappings Symbol Symbol) a Source #
Wrapper for Entity
to be used with DerivingVia
.
This wrappers indicates that the identifier is to be found
as the sole field of another object, like in:
{ id: { key: 3 }, name: "Somebody" }
Instances
(Generic t, Applicative w, (sch :/: sty) ~ DRecord name (nestedIdArg ': args), nestedIdArg ~ FieldDef fname (TSchematic idTy :: FieldTypeB Type Symbol), (sch :/: idTy) ~ DRecord idName (idArg ': ([] :: [FieldDefB Type Symbol Symbol])), idArg ~ FieldDef idArgName (TPrimitive Int64 :: FieldTypeB Type Symbol), Rep t ~ D1 dInfo (C1 cInfo f), GToSchemaRecord Identity sch fmap args f, ToBackendKey (PersistEntityBackend t) t, PersistEntityBackend t ~ SqlBackend) => ToSchema w (sch :: Schema Symbol Symbol) (sty :: Symbol) (WithEntityNestedId sty fmap (Entity t)) Source # | |
Defined in Mu.Adapter.Persistent |
newtype WithEntityPlainId (ty :: Symbol) (fmap :: Mappings Symbol Symbol) a Source #
Wrapper for Entity
to be used with DerivingVia
.
This wrappers indicates that the identifier is to be found
in the schema at the same level as other fields, like in:
{ id: 3, name: "Somebody" }
Instances
(Generic t, Applicative w, (sch :/: sty) ~ DRecord name (idArg ': args), idArg ~ FieldDef idArgName (TPrimitive Int64 :: FieldTypeB Type Symbol), Rep t ~ D1 dInfo (C1 cInfo f), GToSchemaRecord Identity sch fmap args f, ToBackendKey (PersistEntityBackend t) t, PersistEntityBackend t ~ SqlBackend) => ToSchema w (sch :: Schema Symbol Symbol) (sty :: Symbol) (WithEntityPlainId sty fmap (Entity t)) Source # | |
Defined in Mu.Adapter.Persistent |
Generic utilities
runDb :: MonadIO m => SqlBackend -> ReaderT SqlBackend (NoLoggingT (ResourceT IO)) a -> m a Source #
Simple utility to execute a database operation
in any monad which supports IO
operations.
Note that all logging messages are discarded.