persistent-sql-lifted: Monad classes for running queries with Persistent and Esqueleto

[ database, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

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.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies annotated-exception (>=0.2.0.4), base (>=4.16.4.0 && <5), conduit (>=1.3.5), containers (>=0.6.5.1), esqueleto (>=3.5.10.0), mtl (>=2.2.2), persistent (>=2.14.0.1), text (>=1.2.5.0), unliftio-core (>=0.2.1.0) [details]
License MIT
Author
Maintainer Freckle Education
Category Database
Home page https://github.com/freckle/freckle-app#readme
Bug tracker https://github.com/freckle/freckle-app/issues
Source repo head: git clone https://github.com/freckle/freckle-app
Uploaded by PatrickBrisbin at 2024-11-25T20:31:14Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 11 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for persistent-sql-lifted-0.1.0.0

[back to package description]

persistent-sql-lifted

This package introduces two classes:

  • MonadSqlBackend m, for monadic contexts m in which a SqlBackend is available

  • MonadSqlBackend db m, for monadic contexts m in which we can execute a SQL transaction of type db a and get a result m a. (The type db should have an instance of `MonadSqlBackend.)

Additionally, this package provides variants of query-running utilities from persistent and esqueleto which are

  1. Concretized to use SqlBackend;
  2. Generalized to a MonadSqlBackend m constraint rather than ReaderT backend m;
  3. 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 the runSqlTx method from the MonadSqlTx class.