Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Yesod.Session.Persist.Storage
Contents
Synopsis
- persistentStorage :: forall record backend result m. (PersistRecordBackend record backend, PersistStoreWrite backend) => SessionPersistence backend record m -> StorageOperation result -> ReaderT backend IO result
- data SessionPersistence backend record m = (PersistRecordBackend record backend, PersistStoreWrite backend, SafeToInsert record) => SessionPersistence {
- databaseKey :: SessionKey -> Key record
- toDatabase :: Session -> record
- fromDatabase :: record -> Session
- runDB :: forall a. ReaderT backend IO a -> m a
- class (PersistField (Key record), ToJSON (Key record), FromJSON (Key record), Show (Key record), Read (Key record), Eq (Key record), Ord (Key record)) => PersistEntity record
- type family PersistEntityBackend record
- class SafeToInsert a
- type ConnectionPool = Pool SqlBackend
Documentation
persistentStorage :: forall record backend result m. (PersistRecordBackend record backend, PersistStoreWrite backend) => SessionPersistence backend record m -> StorageOperation result -> ReaderT backend IO result Source #
data SessionPersistence backend record m Source #
Mapping between Session
and
a Persistent entity of your choice
Constructors
(PersistRecordBackend record backend, PersistStoreWrite backend, SafeToInsert record) => SessionPersistence | |
Fields
|
Persistent reëxports
class (PersistField (Key record), ToJSON (Key record), FromJSON (Key record), Show (Key record), Read (Key record), Eq (Key record), Ord (Key record)) => PersistEntity record #
Persistent serialized Haskell records to the database.
A Database Entity
(A row in SQL, a document in MongoDB, etc)
corresponds to a Key
plus a Haskell record.
For every Haskell record type stored in the database there is a
corresponding PersistEntity
instance. An instance of PersistEntity
contains meta-data for the record. PersistEntity also helps abstract
over different record types. That way the same query interface can return
a PersistEntity
, with each query returning different types of Haskell
records.
Some advanced type system capabilities are used to make this process type-safe. Persistent users usually don't need to understand the class associated data and functions.
Minimal complete definition
keyToValues, keyFromValues, persistIdField, entityDef, persistFieldDef, toPersistFields, fromPersistValues, tabulateEntityA, persistUniqueKeys, persistUniqueToFieldNames, persistUniqueToValues, fieldLens
type family PersistEntityBackend record #
Persistent allows multiple different backends (databases).
class SafeToInsert a #
A type class which is used to witness that a type is safe to insert into the database without providing a primary key.
The TemplateHaskell
function mkPersist
will generate instances of this
class for any entity that it works on. If the entity has a default primary
key, then it provides a regular instance. If the entity has a Primary
natural key, then this works fine. But if the entity has an Id
column with
no default=
, then this does a TypeError
and forces the user to use
insertKey
.
Since: persistent-2.14.0.0
Instances
(TypeError (EntityErrorMessage a) :: Constraint) => SafeToInsert (Entity a) | |
Defined in Database.Persist.Class.PersistEntity | |
(TypeError (FunctionErrorMessage a b) :: Constraint) => SafeToInsert (a -> b) | |
Defined in Database.Persist.Class.PersistEntity |
type ConnectionPool = Pool SqlBackend #