blob: ddca0fb94da70a48dfceff78ce531ab52619243d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
module Model.User
( getUsers
, getUser
, insertUser
, deleteUser
) where
import Data.Text (Text)
import Data.Time.Clock (getCurrentTime)
import Control.Monad.IO.Class (liftIO)
import Database.Persist
import Model.Database
getUsers :: Persist [User]
getUsers = map entityVal <$> selectList [] [Desc UserCreation]
getUser :: Text -> Persist (Maybe (Entity User))
getUser email = selectFirst [UserEmail ==. email] []
insertUser :: Text -> Text -> Persist UserId
insertUser email name = do
now <- liftIO getCurrentTime
insert $ User now email name
deleteUser :: Text -> Persist ()
deleteUser email =
deleteWhere [UserEmail ==. email]
|