Safe Haskell | None |
---|---|
Language | Haskell2010 |
Storage backend for serversession
using persistent.
In order to use this backend, you have to include
serverSessionDefs
on your migration code. For example,
the Yesod scaffold usually includes the following code:
-- On Model.hs share [mkPersist sqlSettings, mkMigrate "migrateAll"] -- On Application.hs makeFoundation = ... runLoggingT (runSqlPool (runMigration migrateAll) pool) logFunc ...
You should changed those lines to:
-- On Model.hs share [mkPersist sqlSettings, mkSave "entityDefs"] -- On Application.hs import Web.ServerSession.Backend.Persistent mkMigrate "migrateAll" (entityDefs `embedEntityDefs` serverSessionDefsBySessionMap) makeFoundation = ... runLoggingT (runSqlPool (runMigration migrateAll) pool) logFunc ...
If you're not using SessionMap
, just use mkServerSessionDefs
and change Proxy
type above.
If you forget to setup the migration above, this session storage backend will fail at runtime as the required table will not exist.
Synopsis
- newtype SqlStorage sess = SqlStorage {}
- data PersistentSession sess = PersistentSession {}
- type PersistentSessionId sess = Key (PersistentSession sess)
- serverSessionDefsBySessionMap :: [UnboundEntityDef]
- type PersistentSessionBySessionMap = PersistentSession SessionMap
- mkServerSessionDefs :: forall sess. PersistEntity sess => Proxy sess -> Text -> [UnboundEntityDef]
Documentation
newtype SqlStorage sess Source #
SQL session storage backend using persistent
.
SqlStorage | |
|
Instances
data PersistentSession sess Source #
Entity corresponding to a Session
.
We're bending persistent
in ways it wasn't expected to. In
particular, this entity is parametrized over the session type.
PersistentSession | |
|
Instances
type PersistentSessionId sess = Key (PersistentSession sess) Source #
serverSessionDefsBySessionMap :: [UnboundEntityDef] Source #
Simple version.
Entity definitions needed to generate the SQL schema for SqlStorage
.
Example:
mkMigrate "migrateAll" serverSessionDefsBySessionMap
Note: Also import PersistentSessionBySessionMap
in the same module.
mkServerSessionDefs :: forall sess. PersistEntity sess => Proxy sess -> Text -> [UnboundEntityDef] Source #
Entity definitions needed to generate the SQL schema for SqlStorage
.
Generate schema by specifying Haskell name in Text.
Example using SessionMap
:
type PersistentSessionBySessionMap = PersistentSession SessionMap mkMigrate "migrateAll" (mkServerSessionDefs (Proxy :: Proxy PersistentSessionBySessionMap) "PersistentSessionBySessionMap")