blob: 0a29a553c8a6d3ba7223bc90024334dd7e1dc0d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
{-# LANGUAGE OverloadedStrings #-}
module SpaceTraders.Database.Tokens
( addToken
, getToken
) where
import Control.Monad.Reader
import qualified Data.Text as T
import qualified Database.SQLite.Simple as S
import SpaceTraders
import SpaceTraders.Utils
addToken :: (HasDatabaseConn env, MonadIO m, MonadReader env m) => T.Text -> m ()
addToken value = execute "INSERT INTO tokens(data) VALUES (?);" (S.Only value)
getToken :: (HasDatabaseConn env, MonadFail m, MonadIO m, MonadReader env m) => m T.Text
getToken = do
env <- ask
[[token]] <- liftIO $ S.query_ (getConn env) "SELECT data FROM tokens;"
return token
|