db.collection.update(criteria, objNew, upsert, multi) criteria: update query conditions, similar to objNew: update object and some update operators after where in sql update query ( Such as $, $inc...), etc., which can also be understood as the upsert after set in the sql update query: This parameter means whether to insert objNew if there is no update record, true means insert, and the default is false, do not insert. multi: The default value of mongodb is false. Only the first record found is updated. If this parameter is true, all multiple records found according to the conditions will be updated.
For example: db.collection.update({"isValid":1}, {$set:{ "name" : "name john"}}, false, true) Set the value of isValid to The names of all records of 1 are set to "name john"
The last one is updated one by one, there is no other way.
db.collection.update(criteria, objNew, upsert, multi)
criteria: update query conditions, similar to
objNew: update object and some update operators after where in sql update query ( Such as $, $inc...), etc., which can also be understood as the
upsert after set in the sql update query: This parameter means whether to insert objNew if there is no update record, true means insert, and the default is false, do not insert.
multi: The default value of mongodb is false. Only the first record found is updated. If this parameter is true, all multiple records found according to the conditions will be updated.
For example:
db.collection.update({"isValid":1}, {$set:{ "name" : "name john"}}, false, true)
Set the value of isValid to The names of all records of 1 are set to "name john"