Copyright | (C) 2016 Takahiro Himura |
---|---|
License | BSD3 |
Maintainer | Takahiro Himura <taka@himura.jp> |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
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
- runQuery :: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend, ToSql PersistValue p, ToPersistEntity a b) => Query p a -> p -> Source m b
- rawQuery :: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend, ToSql PersistValue p) => Query p a -> p -> Source m [PersistValue]
- mkHrrInstances :: [EntityDef] -> Q [Dec]
- defineTableFromPersistent :: Name -> [EntityDef] -> Q [Dec]
- defineTableFromPersistentWithConfig :: Config -> String -> Name -> [EntityDef] -> Q [Dec]
- defineFromToSqlPersistValue :: TypeQ -> Q [Dec]
- defaultConfig :: Config
- class ToPersistEntity a b | a -> b, b -> a where
Documentation
:: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend, ToSql PersistValue p, ToPersistEntity a b) | |
=> Query p a | Query to get record type a requires parameter p |
-> p | Parameter type |
-> Source m b |
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 -> Source m [PersistValue] Source #
defineTableFromPersistent Source #
:: Name | Name of the persistent record type corresponds to the table |
-> [EntityDef] |
|
-> Q [Dec] |
Generate all templates about table from persistent table definition using default naming rule.
defineTableFromPersistentWithConfig Source #
:: Config | Configration for haskell relational record |
-> String | Database schema name |
-> Name | Name of the persistent record type corresponds to the table |
-> [EntityDef] |
|
-> Q [Dec] |
Generate all templates about table from persistent table definition.
defineFromToSqlPersistValue :: TypeQ -> Q [Dec] Source #
Generate FromSql
PersistValue
and ToSql
PersistValue
instances for PersistField
types.
defaultConfig :: Config #
Default configuration.
class ToPersistEntity a b | a -> b, b -> a where Source #
ToPersistEntity () () Source # | |
(ToPersistEntity a c, ToPersistEntity b d) => ToPersistEntity (a, b) (c, d) Source # | |