diff options
Diffstat (limited to 'src/server/Model/User.hs')
-rw-r--r-- | src/server/Model/User.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/server/Model/User.hs b/src/server/Model/User.hs index 2b52d03..696ef4f 100644 --- a/src/server/Model/User.hs +++ b/src/server/Model/User.hs @@ -1,6 +1,7 @@ module Model.User ( getUsers , getUser + , findUser , getJsonUser , createUser , deleteUser @@ -8,6 +9,7 @@ module Model.User import Data.Text (Text) import Data.Time.Clock (getCurrentTime) +import Data.List (find) import Control.Monad.IO.Class (liftIO) @@ -22,6 +24,9 @@ getUsers = selectList [] [Desc UserCreation] getUser :: Text -> Persist (Maybe (Entity User)) getUser email = selectFirst [UserEmail ==. email] [] +findUser :: UserId -> [Entity User] -> Maybe User +findUser i = fmap entityVal . find ((==) i . entityKey) + getJsonUser :: Entity User -> Json.User getJsonUser userEntity = let user = entityVal userEntity |