robbiblubber.org

help | login | search:  
<<

Home Page
Index

Projects

Utility Suite
Data Suite
Bad Wolf Suite
WeakWiki

User Docs

ConfigNotepad
LED
rqoon
Nuub

Code Docs

.NET
Java
PHP

robbiblubber.org

Specs
Articles

Sources















show wiki  show source  compare to current  compare to previous  read  history 


updateMany()


MongoDB Driver Function Reference


Updates all documents in a collection that meet the filter criteria.

There is no difference in usage and behavior between the update() and updateMany() functions. These functions can be considered synonyms.



db.<collection>.updateMany(<filter>, <update>[, <options>])



Arguments


<collection> The target collection
<filter> A filter expression using query operators
<update> A BSON document containing the modifications to apply
<options> A BOSN document specifying options



Options


{ upsert: <boolean>, arrayFilters: [<document>], collation: <document>, hint: <document>, }

upsert Specifies if a document should be created if no document matches (default: false)
arrayFilters An array of filter documents that determine which array elements to modify for an update operation on an array field.
collation A document specifying the collation
hint A document specifying a hint



Example


db.employees.updateMany({ salary: { $gt: 700000 }}, { $set: { bonus: 50000 }});


Sets the bonus in all documents from the employee collection with a salary greater than 700000 to 50000.




home | MongoDB Driver Function Reference | MongoDB Driver