1. update
db.collection.update(criteria, objNew, upset, multi)
criteria: The search condition of update,
objNew: The object or operator of update, like $set, $inc, $setOnInsert
upsert: If the criteria doesn’t exist, if insert objNew, true is insert, default[false], not insert.
multi: default[false], just update the first record of the founded result, if this argument is true, update all founded records.
Example:
1 | db.test.update( |
Error: “errmsg” : “Updating the path ‘last’ would create a conflict at ‘last’”
1 | db.test.update( |
Reason: There is already $set ‘last’, second time $setOnInsert ‘last’ make a conflict.