Skip to content
Browse files

runMongoDBConn -> runMongoDBPool

  • Loading branch information...
1 parent 00e117c commit 3d766649d0c452591c47033cbed4cce5b82d1cf7 @gregwebs gregwebs committed Aug 6, 2012
Showing with 10 additions and 6 deletions.
  1. +8 −4 persistent-mongoDB/Database/Persist/MongoDB.hs
  2. +2 −2 persistent-test/Init.hs
View
12 persistent-mongoDB/Database/Persist/MongoDB.hs
@@ -11,7 +11,8 @@ module Database.Persist.MongoDB
withMongoDBConn
, withMongoDBPool
, createMongoDBPool
- , runMongoDBConn
+ , runMongoDBPool
+ , runMongoDBPoolDef
, ConnectionPool
, Connection
, MongoConf (..)
@@ -120,12 +121,15 @@ withMongoDBPool dbname hostname mauth poolStripes stripeConnections connectionId
pool <- createMongoDBPool dbname hostname mauth poolStripes stripeConnections connectionIdleTime
connectionReader pool
-runMongoDBConn :: (Trans.MonadIO m, MonadBaseControl IO m) => DB.AccessMode -> DB.Action m backend -> ConnectionPool -> m backend
-runMongoDBConn accessMode action pool =
+runMongoDBPool :: (Trans.MonadIO m, MonadBaseControl IO m) => DB.AccessMode -> DB.Action m a -> ConnectionPool -> m a
+runMongoDBPool accessMode action pool =
Pool.withResource pool $ \(Connection pipe db) -> do
res <- DB.access pipe accessMode db action
either (Trans.liftIO . throwIO . PersistMongoDBError . T.pack . show) return res
+runMongoDBPoolDef :: (Trans.MonadIO m, MonadBaseControl IO m) => DB.Action m a -> ConnectionPool -> m a
+runMongoDBPoolDef = runMongoDBPool (DB.ConfirmWrites ["j" DB.=: True])
+
value :: DB.Field -> DB.Value
value (_ DB.:= val) = val
@@ -581,7 +585,7 @@ instance PersistConfig MongoConf where
(mgAuth c)
(mgPoolStripes c) (mgStripeConnections c) (mgConnectionIdleTime c)
- runPool c = runMongoDBConn (mgAccessMode c)
+ runPool c = runMongoDBPool (mgAccessMode c)
loadConfig (Object o) = do
db <- o .: "database"
host <- o .:? "host" .!= "127.0.0.1"
View
4 persistent-test/Init.hs
@@ -48,7 +48,7 @@ import Database.Persist.Store (PersistValue(..))
#if WITH_MONGODB
import qualified Database.MongoDB as MongoDB
-import Database.Persist.MongoDB (Action, withMongoDBConn, runMongoDBConn)
+import Database.Persist.MongoDB (Action, withMongoDBConn, runMongoDBPool)
{-
import Database.Persist.MongoDB (oidToKey)
import Data.Bson (genObjectId)
@@ -116,7 +116,7 @@ type BackendMonad = Action
runConn :: (MonadIO m, MonadBaseControl IO m) => Action m backend -> m ()
runConn f = do
_<-withMongoDBConn "test" "127.0.0.1" Nothing 5 $
- runMongoDBConn MongoDB.master f
+ runMongoDBPool MongoDB.master f
return ()
--setup :: MongoPersist IO ()

0 comments on commit 3d76664

Please sign in to comment.
Something went wrong with that request. Please try again.