| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Database.Persist.Sql.Lifted.Core
Synopsis
- class (MonadSqlBackend db, MonadUnliftIO m) => MonadSqlTx db m | m -> db where
- runSqlTx :: forall a. HasCallStack => db a -> m a
- class HasSqlBackend a where
- getSqlBackend :: a -> SqlBackend
- data SqlBackend
- class MonadUnliftIO m => MonadSqlBackend m where
- getSqlBackendM :: m SqlBackend
- liftSql :: forall m a. (HasCallStack, MonadSqlBackend m) => ReaderT SqlBackend m a -> m a
Documentation
class (MonadSqlBackend db, MonadUnliftIO m) => MonadSqlTx db m | m -> db where Source #
The constraint indicates that MonadSqlTx db mm is a monadic
context that can run db actions, usually as a SQL transaction.
Typically, this means that db needs a connection and m can
provide one, e.g. from a connection pool.
Methods
runSqlTx :: forall a. HasCallStack => db a -> m a Source #
Runs the action in a SQL transaction
class HasSqlBackend a where Source #
Methods
getSqlBackend :: a -> SqlBackend Source #
Instances
| HasSqlBackend SqlBackend Source # | |
Defined in Database.Persist.Sql.Lifted.HasSqlBackend Methods getSqlBackend :: SqlBackend -> SqlBackend Source # | |
data SqlBackend #
A SqlBackend represents a handle or connection to a database. It
contains functions and values that allow databases to have more
optimized implementations, as well as references that benefit
performance and sharing.
Instead of using the SqlBackend constructor directly, use the
mkSqlBackend function.
A SqlBackend is *not* thread-safe. You should not assume that
a SqlBackend can be shared among threads and run concurrent queries.
This *will* result in problems. Instead, you should create a , known as a Pool
SqlBackendConnectionPool, and pass that around in
multi-threaded applications.
To run actions in the persistent library, you should use the
runSqlConn function. If you're using a multithreaded application, use
the runSqlPool function.
Instances
| HasPersistBackend SqlBackend | |
Defined in Database.Persist.SqlBackend.Internal Associated Types type BaseBackend SqlBackend # Methods | |
| IsPersistBackend SqlBackend | |
Defined in Database.Persist.SqlBackend.Internal Methods | |
| HasSqlBackend SqlBackend Source # | |
Defined in Database.Persist.Sql.Lifted.HasSqlBackend Methods getSqlBackend :: SqlBackend -> SqlBackend Source # | |
| newtype BackendKey SqlBackend | |
Defined in Database.Persist.Sql.Orphan.PersistStore | |
| type BaseBackend SqlBackend | |
Defined in Database.Persist.SqlBackend.Internal | |
| type Rep (BackendKey SqlBackend) | |
Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.15.1.0-18EFgO0PgmjDdch24u6s9Z" 'True) (C1 ('MetaCons "SqlBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64))) | |
class MonadUnliftIO m => MonadSqlBackend m where Source #
A monadic context in which a SQL backend is available for running database queries
Methods
getSqlBackendM :: m SqlBackend Source #
Instances
| (HasSqlBackend r, MonadUnliftIO m) => MonadSqlBackend (ReaderT r m) Source # | |
Defined in Database.Persist.Sql.Lifted.MonadSqlBackend Methods getSqlBackendM :: ReaderT r m SqlBackend Source # | |
liftSql :: forall m a. (HasCallStack, MonadSqlBackend m) => ReaderT SqlBackend m a -> m a Source #
Generalize from SqlPersistT to MonadSqlBackend