From d1d5f84b2265934c2323656d779d5d802e40d7d9 Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Sat, 21 Jan 2017 17:16:59 -0800 Subject: [PATCH] Keep old behavior of update --- Database/MongoDB/Query.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Database/MongoDB/Query.hs b/Database/MongoDB/Query.hs index 001a32f..91cfdeb 100644 --- a/Database/MongoDB/Query.hs +++ b/Database/MongoDB/Query.hs @@ -68,7 +68,7 @@ import Control.Concurrent.MVar.Lifted (MVar, newMVar, addMVarFinalizer, #endif import Control.Applicative ((<$>)) import Control.Exception (catch) -import Control.Monad (when) +import Control.Monad (when, void) import Control.Monad.Base (MonadBase) import Control.Monad.Error (Error(..)) import Control.Monad.Reader (MonadReader, ReaderT, runReaderT, ask, asks, local) @@ -618,10 +618,9 @@ update :: (MonadIO m) => [UpdateOption] -> Selection -> Document -> Action m () -- ^ Update first document in selection using updater document, unless 'MultiUpdate' option is supplied then update all documents in selection. If 'Upsert' option is supplied then treat updater as document and insert it if selection is empty. update opts (Select sel col) up = do - res <- update' True col [(sel, up, opts)] - if not $ null $ writeErrors res - then liftIO $ throwIO $ WriteFailure 0 0 (show $ head $ writeErrors res) - else return () + db <- thisDatabase + ctx <- ask + liftIO $ runReaderT (void $ write (Update (db <.> col) opts sel up)) ctx updateCommandDocument :: Collection -> Bool -> [Document] -> Document -> Document updateCommandDocument col ordered updates writeConcern =