diff --git a/Database/MongoDB/Query.hs b/Database/MongoDB/Query.hs index e8c316d..77a4049 100644 --- a/Database/MongoDB/Query.hs +++ b/Database/MongoDB/Query.hs @@ -574,8 +574,10 @@ 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 - _ <- update' True col [(sel, up, opts)] - return () + res <- update' True col [(sel, up, opts)] + if not $ null $ writeErrors res + then liftIO $ throwIO $ WriteFailure 0 (show $ head $ writeErrors res) + else return () updateCommandDocument :: Collection -> Bool -> [Document] -> Document -> Document updateCommandDocument col ordered updates writeConcern =