| Copyright | (C) 2016 Takahiro Himura |
|---|---|
| License | BSD3 |
| Maintainer | Takahiro Himura <taka@himura.jp> |
| Stability | experimental |
| Portability | unknown |
| Safe Haskell | None |
| Language | Haskell2010 |
Database.Persist.Relational
Description
This module works as a bridge between Haskell Relational Record and Persistent. It uses the persistent entities definition instead of obtaining schema from DB at compilation time.
See: https://github.com/himura/persistent-relational-record#readme
Synopsis
- runQuery :: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend, FromSql PersistValue a, ToSql PersistValue p) => Query p a -> p -> ConduitT () a m ()
- rawQuery :: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend, ToSql PersistValue p) => Query p a -> p -> ConduitT () [PersistValue] m ()
- mkHrr :: [EntityDef] -> Q [Dec]
- mkHrrWithConfig :: NameConfig -> [EntityDef] -> Q [Dec]
- deriveGenericForEntityId :: [EntityDef] -> Q [Dec]
- defineFromToSqlPersistValue :: TypeQ -> Q [Dec]
- module Database.Persist.Relational.Config
Documentation
Arguments
| :: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend, FromSql PersistValue a, ToSql PersistValue p) | |
| => Query p a | Query to get record type a requires parameter p |
| -> p | Parameter type |
| -> ConduitT () a m () |
Execute a HRR Query and return the stream of its results.
rawQuery :: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend, ToSql PersistValue p) => Query p a -> p -> ConduitT () [PersistValue] m () Source #
mkHrrWithConfig :: NameConfig -> [EntityDef] -> Q [Dec] Source #
deriveGenericForEntityId :: [EntityDef] -> Q [Dec] Source #
standalone deriving Generic instance for entity IDs.
Persistent does not derive Generic instances for `Key a`. see https://github.com/yesodweb/persistent/pull/734#issuecomment-346696921 https://github.com/yesodweb/persistent/issues/578
defineFromToSqlPersistValue :: TypeQ -> Q [Dec] Source #
Generate FromSql PersistValue and ToSql PersistValue instances for PersistField types.