Monad classes for running queries with Persistent and Esqueleto.
This package introduces two classes: MonadSqlBackend for monadic contexts in which a SqlBackend is available, and MonadSqlBackend for contexts in which we can execute a SQL transaction.
Additionally, this package provides variants of query-running utilities from Persistent and Esqueleto which are concretized to use SqlBackend, generalized to a MonadSqlBackend m constraint rather than "ReaderT backend", and wrapped in checkpointCallStack so that exceptions will include call stacks.
persistent-sql-lifted
This package introduces two classes:
MonadSqlBackend m
, for monadic contextsm
in which aSqlBackend
is availableMonadSqlBackend db m
, for monadic contextsm
in which we can execute a SQL transaction of typedb a
and get a resultm a
. (The typedb
should have an instance of `MonadSqlBackend.)
Additionally, this package provides variants of query-running utilities from persistent and esqueleto which are
- Concretized to use
SqlBackend
; - Generalized to a
MonadSqlBackend m
constraint rather thanReaderT backend m
; - Wrapped in checkpointCallStack so that exceptions will include call stacks.
How to migrate from vanilla persistent/esqueleto:
Instead of SqlPersistT, use a
MonadSqlBackend
constraint.Define an instance of
MonadSqlTx
for your application Monad that specifies how your application runs database transactions, e.g. by running runSqlPool.Instead of calling
runSqlPool
directly from the rest of your application code, use therunSqlTx
method from theMonadSqlTx
class.