Find And Modify

Find And Modify

   On mongoDB collection there is findAndModify command that allows user to return either original or updated document
   when performing document update.

   This is implemented in MongoStreams as two separate operations:
 query("key1" === 1) and updateOne("key" := 33)
   and for document removal
 query("key1" === 1) and removeOne
   Both variants support additional modifiers:

   To return new document instead of old one:                     
 query("key1" === 1) and updateOne("key" := 33).returnNew(true)
   To first sort the documents before picking one to update:      
 query().sort("key" Descending) and updateOne("key" := 33)
   To limit the keys in returned document using projection:       
 query("key1" === 1).project("key" include) and updateOne("key" := 33)
   To first sort documents before actually removing them:         
 query().sort("key" Descending) and removeOne
   To limit the keys in returned document once removed:           
 query("key1" === 1).project("key" include) and removeOne

Total for specification CollectionFindAndModifySpec
Finished in1 second, 861 ms
Results7 examples, 0 failure, 0 error