serversession-backend-persistent-1.0.4: Storage backend for serversession using persistent and an RDBMS.

Safe HaskellNone
LanguageHaskell98

Web.ServerSession.Backend.Persistent.Internal.Impl

Description

Internal module exposing the guts of the package. Use at your own risk. No API stability guarantees apply.

Synopsis

Documentation

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.

Constructors

PersistentSession 

Fields

Instances

Eq (Key (PersistentSession sess)) Source # 

Methods

(==) :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Bool #

(/=) :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Bool #

Eq (Decomposed sess) => Eq (PersistentSession sess) Source # 
Ord (Key (PersistentSession sess)) Source # 

Methods

compare :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Ordering #

(<) :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Bool #

(<=) :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Bool #

(>) :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Bool #

(>=) :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Bool #

max :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Key (PersistentSession sess) #

min :: Key (PersistentSession sess) -> Key (PersistentSession sess) -> Key (PersistentSession sess) #

Ord (Decomposed sess) => Ord (PersistentSession sess) Source # 
Read (Key (PersistentSession sess)) Source # 
Show (Key (PersistentSession sess)) Source # 

Methods

showsPrec :: Int -> Key (PersistentSession sess) -> ShowS #

show :: Key (PersistentSession sess) -> String #

showList :: [Key (PersistentSession sess)] -> ShowS #

Show (Decomposed sess) => Show (PersistentSession sess) Source # 
ToJSON (Key (PersistentSession sess)) Source # 

Methods

toJSON :: Key (PersistentSession sess) -> Value

toEncoding :: Key (PersistentSession sess) -> Encoding

toJSONList :: [Key (PersistentSession sess)] -> Value

toEncodingList :: [Key (PersistentSession sess)] -> Encoding

(ToJSON (Decomposed sess), PersistFieldSql (Decomposed sess)) => ToJSON (Entity (PersistentSession sess)) Source # 

Methods

toJSON :: Entity (PersistentSession sess) -> Value

toEncoding :: Entity (PersistentSession sess) -> Encoding

toJSONList :: [Entity (PersistentSession sess)] -> Value

toEncodingList :: [Entity (PersistentSession sess)] -> Encoding

ToJSON (Decomposed sess) => ToJSON (PersistentSession sess) Source # 

Methods

toJSON :: PersistentSession sess -> Value

toEncoding :: PersistentSession sess -> Encoding

toJSONList :: [PersistentSession sess] -> Value

toEncodingList :: [PersistentSession sess] -> Encoding

PersistField (Key (PersistentSession sess)) Source # 

Methods

toPersistValue :: Key (PersistentSession sess) -> PersistValue

fromPersistValue :: PersistValue -> Either Text (Key (PersistentSession sess))

PersistFieldSql (Decomposed sess) => PersistEntity (PersistentSession sess) Source # 

Associated Types

type PersistEntityBackend (PersistentSession sess) :: *

data Key (PersistentSession sess) :: *

data EntityField (PersistentSession sess) a :: * #

data Unique (PersistentSession sess) :: *

Methods

keyToValues :: Key (PersistentSession sess) -> [PersistValue]

keyFromValues :: [PersistValue] -> Either Text (Key (PersistentSession sess))

persistIdField :: EntityField (PersistentSession sess) (Key (PersistentSession sess))

entityDef :: Monad m => m (PersistentSession sess) -> EntityDef

persistFieldDef :: EntityField (PersistentSession sess) typ -> FieldDef

toPersistFields :: PersistentSession sess -> [SomePersistField]

fromPersistValues :: [PersistValue] -> Either Text (PersistentSession sess)

persistUniqueKeys :: PersistentSession sess -> [Unique (PersistentSession sess)]

persistUniqueToFieldNames :: Unique (PersistentSession sess) -> [(HaskellName, DBName)]

persistUniqueToValues :: Unique (PersistentSession sess) -> [PersistValue]

fieldLens :: EntityField (PersistentSession sess) field -> forall f. Functor f => (field -> f field) -> Entity (PersistentSession sess) -> f (Entity (PersistentSession sess))

PersistFieldSql (Key (PersistentSession sess)) Source # 

Methods

sqlType :: Proxy * (Key (PersistentSession sess)) -> SqlType

PathPiece (Key (PersistentSession sess)) Source # 

Methods

fromPathPiece :: Text -> Maybe (Key (PersistentSession sess))

toPathPiece :: Key (PersistentSession sess) -> Text

FromJSON (Key (PersistentSession sess)) Source # 

Methods

parseJSON :: Value -> Parser (Key (PersistentSession sess))

parseJSONList :: Value -> Parser [Key (PersistentSession sess)]

(FromJSON (Decomposed sess), PersistFieldSql (Decomposed sess)) => FromJSON (Entity (PersistentSession sess)) Source # 

Methods

parseJSON :: Value -> Parser (Entity (PersistentSession sess))

parseJSONList :: Value -> Parser [Entity (PersistentSession sess)]

FromJSON (Decomposed sess) => FromJSON (PersistentSession sess) Source # 

Methods

parseJSON :: Value -> Parser (PersistentSession sess)

parseJSONList :: Value -> Parser [PersistentSession sess]

data Unique (PersistentSession sess) Source # 
data Unique (PersistentSession sess)
type PersistEntityBackend (PersistentSession sess) Source # 
type PersistEntityBackend (PersistentSession sess) = SqlBackend
data Key (PersistentSession sess) Source # 
data Key (PersistentSession sess) = PersistentSessionKey' {}
data EntityField (PersistentSession sess) Source # 

serverSessionDefs :: forall sess. PersistEntity (PersistentSession sess) => Proxy sess -> [EntityDef] Source #

Entity definitions needed to generate the SQL schema for SqlStorage. Example using SessionMap:

serverSessionDefs (Proxy :: Proxy SessionMap)

psKey :: SessionId sess -> Key (PersistentSession sess) Source #

Generate a key to the entity from the session ID.

toPersistentSession :: Session sess -> PersistentSession sess Source #

Convert from Session to PersistentSession.

fromPersistentSession :: PersistentSession sess -> Session sess Source #

Convert from PersistentSession to Session.

newtype SqlStorage sess Source #

SQL session storage backend using persistent.

Constructors

SqlStorage 

Fields

  • connPool :: ConnectionPool

    Pool of DB connections. You may use the same pool as your application.

Instances

(IsSessionData sess, PersistFieldSql (Decomposed sess)) => Storage (SqlStorage sess) Source # 

Associated Types

type SessionData (SqlStorage sess) :: *

type TransactionM (SqlStorage sess) :: * -> *

Methods

runTransactionM :: SqlStorage sess -> TransactionM (SqlStorage sess) a -> IO a

getSession :: SqlStorage sess -> SessionId (SessionData (SqlStorage sess)) -> TransactionM (SqlStorage sess) (Maybe (Session (SessionData (SqlStorage sess))))

deleteSession :: SqlStorage sess -> SessionId (SessionData (SqlStorage sess)) -> TransactionM (SqlStorage sess) ()

deleteAllSessionsOfAuthId :: SqlStorage sess -> AuthId -> TransactionM (SqlStorage sess) ()

insertSession :: SqlStorage sess -> Session (SessionData (SqlStorage sess)) -> TransactionM (SqlStorage sess) ()

replaceSession :: SqlStorage sess -> Session (SessionData (SqlStorage sess)) -> TransactionM (SqlStorage sess) ()

type TransactionM (SqlStorage sess) Source # 
type TransactionM (SqlStorage sess) = SqlPersistT IO
type SessionData (SqlStorage sess) Source # 
type SessionData (SqlStorage sess) = sess

throwSS :: Storage (SqlStorage sess) => StorageException (SqlStorage sess) -> TransactionM (SqlStorage sess) a Source #

Specialization of throwIO for SqlStorage.