diff options
Diffstat (limited to 'src/server/Json.hs')
-rw-r--r-- | src/server/Json.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/server/Json.hs b/src/server/Json.hs index a2f1ef5..408742a 100644 --- a/src/server/Json.hs +++ b/src/server/Json.hs @@ -1,7 +1,9 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE FlexibleContexts #-} module Json ( jsonObject + , jsonId ) where import Web.Scotty @@ -10,5 +12,13 @@ import qualified Data.Aeson.Types as Json import qualified Data.HashMap.Strict as M import Data.Text (Text) +import Database.Persist +import Database.Persist.Sqlite + +import Model.Database + jsonObject :: [(Text, Json.Value)] -> ActionM () jsonObject = json . Json.Object . M.fromList + +jsonId :: (ToBackendKey SqlBackend a) => Key a -> ActionM () +jsonId key = json . Json.Object . M.fromList $ [("id", Json.Number . fromIntegral . keyToInt64 $ key)] |