Please enable JavaScript.
Coggle requires JavaScript to display documents.
MONGO-DB_4 UPDATING - Coggle Diagram
MONGO-DB_4
UPDATING
DOING
db.collection
.updateOne(..)
searchObj
updateObj
updateObj
{ $set : {age: 27} }
RETURNS
{acknowledged: true,
insertedId:null,
matchedCount: 1,
modifiedCount: 1,
upsertedCount:0}
Insert-If
No-Match
USING-ID
SearchObj
{_id: ObjectId(...)}
INCREMENT
UpdateObj
{ $inc: {age: 3}}
RENAME-FIELD
UpdateObj
{ $rename:
{name: "firstName"} }
REMOVE-FIELD
UpdateObj
{ $unset: {age: ""}}
Value
CanBe
Anything
As-It-Is
Removed
ARRAY
Add
{ $push:
{ hobbies: "Swimming"} }
UpdateObj
Remove
{ $pull:
{ hobbies: "Swimming"} }
Can
SearchObj
{ hobbies: seachObj }
MULTIPLE
.updateMany(..)
searchObj
updateObj