Safe Haskell | None |
---|
- class Monad (YesodPersistBackend site (HandlerT site IO)) => YesodPersist site where
- type YesodPersistBackend site :: (* -> *) -> * -> *
- runDB :: YesodDB site a -> HandlerT site IO a
- defaultRunDB :: PersistConfig c => (site -> c) -> (site -> PersistConfigPool c) -> PersistConfigBackend c (HandlerT site IO) a -> HandlerT site IO a
- class YesodPersist site => YesodPersistRunner site where
- defaultGetDBRunner :: YesodPersistBackend site ~ SqlPersistT => (site -> Pool Connection) -> HandlerT site IO (DBRunner site, HandlerT site IO ())
- newtype DBRunner site = DBRunner {
- runDBRunner :: forall a. YesodDB site a -> HandlerT site IO a
- runDBSource :: YesodPersistRunner site => Source (YesodDB site) a -> Source (HandlerT site IO) a
- respondSourceDB :: YesodPersistRunner site => ContentType -> Source (YesodDB site) (Flush Builder) -> HandlerT site IO TypedContent
- type YesodDB site = YesodPersistBackend site (HandlerT site IO)
- get404 :: (PersistStore (t m), PersistEntity val, Monad (t m), m ~ HandlerT site IO, MonadTrans t, PersistMonadBackend (t m) ~ PersistEntityBackend val) => Key val -> t m val
- getBy404 :: (PersistUnique (t m), PersistEntity val, m ~ HandlerT site IO, Monad (t m), MonadTrans t, PersistEntityBackend val ~ PersistMonadBackend (t m)) => Unique val -> t m (Entity val)
- module Database.Persist
- module Database.Persist.TH
Documentation
class Monad (YesodPersistBackend site (HandlerT site IO)) => YesodPersist site whereSource
type YesodPersistBackend site :: (* -> *) -> * -> *Source
defaultRunDB :: PersistConfig c => (site -> c) -> (site -> PersistConfigPool c) -> PersistConfigBackend c (HandlerT site IO) a -> HandlerT site IO aSource
Helper for creating runDB
.
Since 1.2.0
class YesodPersist site => YesodPersistRunner site whereSource
Since 1.2.0
getDBRunner :: HandlerT site IO (DBRunner site, HandlerT site IO ())Source
This function differs from runDB
in that it returns a database
runner function, as opposed to simply running a single action. This will
usually mean that a connection is taken from a pool and then reused for
each invocation. This can be useful for creating streaming responses;
see runDBSource
.
It additionally returns a cleanup function to free the connection. If your code finishes successfully, you must call this cleanup to indicate changes should be committed. Otherwise, for SQL backends at least, a rollback will be used instead.
Since 1.2.0
defaultGetDBRunner :: YesodPersistBackend site ~ SqlPersistT => (site -> Pool Connection) -> HandlerT site IO (DBRunner site, HandlerT site IO ())Source
Helper for implementing getDBRunner
.
Since 1.2.0
runDBSource :: YesodPersistRunner site => Source (YesodDB site) a -> Source (HandlerT site IO) aSource
Like runDB
, but transforms a Source
. See respondSourceDB
for an
example, practical use case.
Since 1.2.0
respondSourceDB :: YesodPersistRunner site => ContentType -> Source (YesodDB site) (Flush Builder) -> HandlerT site IO TypedContentSource
Extends respondSource
to create a streaming database response body.
type YesodDB site = YesodPersistBackend site (HandlerT site IO)Source
get404 :: (PersistStore (t m), PersistEntity val, Monad (t m), m ~ HandlerT site IO, MonadTrans t, PersistMonadBackend (t m) ~ PersistEntityBackend val) => Key val -> t m valSource
Get the given entity by ID, or return a 404 not found if it doesn't exist.
getBy404 :: (PersistUnique (t m), PersistEntity val, m ~ HandlerT site IO, Monad (t m), MonadTrans t, PersistEntityBackend val ~ PersistMonadBackend (t m)) => Unique val -> t m (Entity val)Source
Get the given entity by unique key, or return a 404 not found if it doesn't exist.
module Database.Persist
module Database.Persist.TH