module TsWeb.Tables.Session where
import Data.Text (Text)
import Data.Time.Clock (UTCTime)
import Database.Beam
data SessionT d f = Session
{ _sessionId :: C f Text
, _sessionCsrf :: C f Text
, _sessionExpires :: C f UTCTime
, _sessionData :: d f
} deriving (Generic)
type Session d = SessionT d Identity
type SessionId d = PrimaryKey (SessionT d) Identity
deriving instance Show (PrimaryKey (SessionT d) Identity)
deriving instance Show (d Identity) => Show (Session d)
deriving instance Eq (PrimaryKey (SessionT d) Identity)
deriving instance Eq (d Identity) => Eq (Session d)
deriving instance Ord (PrimaryKey (SessionT d) Identity)
deriving instance Ord (d Identity) => Ord (Session d)
instance Beamable (PrimaryKey (SessionT d))
instance Beamable d => Beamable (SessionT d)
instance (Beamable d, Typeable d) => Table (SessionT d) where
data PrimaryKey (SessionT d) f = SessionId (Columnar f Text)
deriving Generic
primaryKey = SessionId . _sessionId