git.mcksp
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
module Repos.Sessions
    ( create
    , delete
    ) where

import Database.SQLite.Simple (Only(..))
import Database.SQLite.Simple.QQ
import Models
import Data.Text
import Repos.Utils

create :: (CanDB m) => Session -> m (DbR)
create session = execute [sql|
    insert into sessions (token, user_id, expire_at) values (?, ?, ?)
    |] session

delete :: (CanDB m) => Text -> m (DbR)
delete sessionId = execute [sql|
    delete from sessions where token = (?)
    |] (Only sessionId)