subtree(users/wpcarro): docking briefcase at '24f5a642'
git-subtree-dir: users/wpcarro git-subtree-mainline:464bbcb15cgit-subtree-split:24f5a642afChange-Id: I6105b3762b79126b3488359c95978cadb3efa789
This commit is contained in:
commit
019f8fd211
766 changed files with 175420 additions and 0 deletions
21
users/wpcarro/assessments/tt/src/Invitations.hs
Normal file
21
users/wpcarro/assessments/tt/src/Invitations.hs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
--------------------------------------------------------------------------------
|
||||
module Invitations where
|
||||
--------------------------------------------------------------------------------
|
||||
import Database.SQLite.Simple
|
||||
|
||||
import qualified Types as T
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
create :: FilePath -> T.InvitationSecret -> T.Email -> T.Role -> IO ()
|
||||
create dbFile secret email role = withConnection dbFile $ \conn -> do
|
||||
execute conn "INSERT INTO Invitations (email,role,secret) VALUES (?,?,?)"
|
||||
(email, role, secret)
|
||||
|
||||
get :: FilePath -> T.Email -> IO (Maybe T.Invitation)
|
||||
get dbFile email = withConnection dbFile $ \conn -> do
|
||||
res <- query conn "SELECT email,role,secret FROM Invitations WHERE email = ?" (Only email)
|
||||
case res of
|
||||
[x] -> pure (Just x)
|
||||
_ -> pure Nothing
|
||||
Loading…
Add table
Add a link
Reference in a new issue