persistent-mongoDB 2.0.3 → 2.0.3.1
raw patch · 2 files changed
+18/−7 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Database/Persist/MongoDB.hs +17/−6
- persistent-mongoDB.cabal +1/−1
Database/Persist/MongoDB.hs view
@@ -102,6 +102,7 @@ import qualified Control.Monad.IO.Class as Trans import Control.Exception (throw, throwIO)+import Data.Acquire (mkAcquire) import Data.Bson (ObjectId(..)) import qualified Database.MongoDB as DB@@ -343,7 +344,7 @@ -- | use default 'AccessMode' runMongoDBPoolDef :: (Trans.MonadIO m, MonadBaseControl IO m) => DB.Action m a -> ConnectionPool -> m a-runMongoDBPoolDef = runMongoDBPool (DB.ConfirmWrites ["j" DB.=: True])+runMongoDBPoolDef = runMongoDBPool defaultAccessMode queryByKey :: (PersistEntity record, PersistEntityBackend record ~ DB.MongoContext) => Key record -> DB.Query@@ -632,13 +633,21 @@ query = DB.select (filtersToDoc filts) $ collectionName $ dummyFromFilts filts + -- | uses cursor options NoCursorTimeout+ -- If there is no sorting, it will turn the $snapshot option on+ -- and explicitly closes the cursor when done selectSourceRes filts opts = do context <- ask- let make = do- cursor <- liftIO $ runReaderT (DB.find $ makeQuery filts opts) context- pull context cursor- return $ return make+ return (pull context `fmap` mkAcquire (open context) (close context)) where+ close :: DB.MongoContext -> DB.Cursor -> IO ()+ close context cursor = runReaderT (DB.closeCursor cursor) context+ open :: DB.MongoContext -> IO DB.Cursor+ open = runReaderT (DB.find (makeQuery filts opts)+ -- it is an error to apply $snapshot when sorting+ { DB.snapshot = noSort+ , DB.options = [DB.NoCursorTimeout]+ }) pull context cursor = do mdoc <- liftIO $ runReaderT (DB.nextBatch cursor) context case mdoc of@@ -647,6 +656,8 @@ forM_ docs $ fromPersistValuesThrow t >=> yield pull context cursor t = entityDef $ Just $ dummyFromFilts filts+ (_, _, orders) = limitOffsetOrder opts+ noSort = null orders selectFirst filts opts = do mdoc <- DB.findOne $ makeQuery filts opts@@ -1016,7 +1027,7 @@ defaultHost :: Text defaultHost = "127.0.0.1" defaultAccessMode :: DB.AccessMode-defaultAccessMode = DB.ConfirmWrites ["j" DB.=: True]+defaultAccessMode = DB.ConfirmWrites ["w" DB.:= DB.Int32 1] defaultPoolStripes, defaultStripeConnections :: Int defaultPoolStripes = 1 defaultStripeConnections = 10
persistent-mongoDB.cabal view
@@ -1,5 +1,5 @@ name: persistent-mongoDB-version: 2.0.3+version: 2.0.3.1 license: MIT license-file: LICENSE author: Greg Weber <greg@gregweber.info>