From dcd0a7a9b2612f383c1f627c72c27868c367058d Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 21 Jul 2023 00:01:02 +0200 Subject: [haskell] abstracted away common database access patterns --- haskell/src/SpaceTraders/Database/Systems.hs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'haskell/src/SpaceTraders/Database/Systems.hs') diff --git a/haskell/src/SpaceTraders/Database/Systems.hs b/haskell/src/SpaceTraders/Database/Systems.hs index d3d19c7..07749be 100644 --- a/haskell/src/SpaceTraders/Database/Systems.hs +++ b/haskell/src/SpaceTraders/Database/Systems.hs @@ -7,7 +7,6 @@ module SpaceTraders.Database.Systems import Control.Monad.Reader import Data.Aeson -import Data.Maybe import qualified Database.SQLite.Simple as S import SpaceTraders @@ -21,7 +20,4 @@ addSystems systems = do liftIO $ S.withTransaction conn $ S.executeMany conn "INSERT INTO systems(data) VALUES (json(?));" $ S.Only <$> map encode systems getSystems :: (HasDatabaseConn env, MonadIO m, MonadReader env m) => m [System] -getSystems = do - env <- ask - ret <- liftIO $ S.query_ (getConn env) "SELECT data FROM systems;" - return . catMaybes $ map (decodeText . head) ret +getSystems = query_ "SELECT data FROM systems;" -- cgit v1.2.3