Conclusion / Learn

MongoDB CRUD Operations: Replace and Delete Documents

In this unit, you learned how to modify query results with MongoDB. Specifically, you:

  • Replaced a single document by using db.collection.replaceOne().
  • Updated a field value by using the $set update operator in db.collection.updateOne().
  • Added a value to an array by using the $push update operator in db.collection.updateOne().
  • Added a new field value to a document by using the upsert option in db.collection.updateOne().
  • Found and modified a document by using db.collection.findAndModify().
  • Updated multiple documents by using db.collection.updateMany().
  • Deleted a document by using db.collection.deleteOne().


Resources

Use the following resources to learn more about modifying query results in MongoDB:

Lesson 01: Replacing a Document in MongoDB

Lesson 02: Updating MongoDB Documents by Using updateOne()

Lesson 03: Updating MongoDB Documents by Using findAndModify()

Lesson 04: Updating MongoDB Documents by Using findAndModify()

Lesson 05: Deleting Documents in MongoDB