Throw exceptions in case of single document updates

This commit is contained in:
Victor Denisov 2016-08-22 21:36:10 -07:00
parent 5812753217
commit 5254793767

View file

@ -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 =