Please enable JavaScript.
Coggle requires JavaScript to display documents.
MongoDB CRUD Operations: Replace and Delete Documents - Coggle Diagram
MongoDB CRUD Operations: Replace and Delete Documents
Replacing Documents
replaceOne(): Replace an entire document with a new one
using db.collection.replaceOne()
Finding and Modifying
findAndModify(): Find and modify a document in one step
Deleting Documents
deleteOne(): Delete a specific document
using db.collection.deleteOne()
Update Document
Updating Field Values
updateOne() with $set: Change specific values within a document
using the $set update operator in db.collection.updateOne(
Updating Multiple Documents
updateMany(): Change documents that meet specific criteria
using db.collection.updateMany()
Adding a New Field
updateOne() with upsert: Add a new field if the document doesn't exist
using the upsert option in db.collection.updateOne()
Adding to an Array
updateOne() with $push: Add a new element to an array within a document
using the $push update operator in db.collection.updateOne()