persistent-mongoDB 1.2.1.2 → 1.2.2
raw patch · 2 files changed
+5/−24 lines, 2 filesdep ~mongoDB
Dependency ranges changed: mongoDB
Files
- Database/Persist/MongoDB.hs +3/−22
- persistent-mongoDB.cabal +2/−2
Database/Persist/MongoDB.hs view
@@ -371,26 +371,6 @@ keyToMongoIdField k = _id DB.:= (DB.ObjId $ keyToOid k) -findAndModifyOne :: (Applicative m, Trans.MonadIO m)- => DB.Collection- -> DB.ObjectId -- ^ _id for query- -> [DB.Field] -- ^ updates- -> DB.Action m (Either String DB.Document)-findAndModifyOne coll objectId updates = do- result <- DB.runCommand [- "findAndModify" DB.:= DB.String coll,- "new" DB.:= DB.Bool True, -- return updated document, not original document- "query" DB.:= DB.Doc [_id DB.:= DB.ObjId objectId],- "update" DB.:= DB.Doc updates- ]- return $ case findErr result of- Nothing -> case DB.lookup "value" result of- Nothing -> Left "no value field"- Just doc -> Right doc- Just e -> Left e- where- findErr result = DB.lookup "err" =<< (DB.lookup "lastErrorObject" result)- instance (Applicative m, Functor m, Trans.MonadIO m, MonadBaseControl IO m) => PersistQuery (DB.Action m) where update _ [] = return () update key upds =@@ -399,8 +379,9 @@ $ updateFields upds updateGet key upds = do- result <- findAndModifyOne (unDBName $ entityDB t)- (keyToOid key) (updateFields upds)+ result <- DB.findAndModify (DB.select [keyToMongoIdField key]+ (unDBName $ entityDB t)+ ) (updateFields upds) case result of Left e -> err e Right doc -> do
persistent-mongoDB.cabal view
@@ -1,5 +1,5 @@ name: persistent-mongoDB-version: 1.2.1.2+version: 1.2.2 license: MIT license-file: LICENSE author: Greg Weber <greg@gregweber.info>@@ -25,7 +25,7 @@ , bytestring >= 0.9 , conduit >= 0.5.3 , resourcet >= 0.3- , mongoDB >= 1.3 && < 1.4.1+ , mongoDB >= 1.4.1 && < 1.5 , bson >= 0.2 && < 0.3 , network >= 2.2.1.7 , cereal >= 0.3.0.0