MongoDB CRUD Operations: Replace and Delete Documents
Learn how to replace and delete documents in the mongo shell.
MongoDB CRUD Operations: Replace and Delete Documents
Unit Overview
In this unit, you’ll learn how to update, replace, and delete documents in MongoDB. These commands will help you manipulate data in your database and will prepare you to build MongoDB into your own apps. We will replace entire documents, update individual fields in a document, insert new documents, and remove documents from a database. By the end of this unit, you'll be able to execute most of the common database operations.
Prerequisites
- Getting Started with MongoDB Atlas
- MongoDB and the Document Model
- MongoDB CRUD Operations: Insert and Find
Lessons in This Unit
- 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
updateMany() - Lesson 05: Deleting Documents in MongoDB
-
01.
-
02.Lesson 2: Updating MongoDB Documents by Using updateOne()
- Learn
- Practice
-
03.Lesson 3: Updating MongoDB Documents by Using findAndModify()
- Learn
- Practice
-
04.Lesson 4: Updating MongoDB Documents by Using updateMany()
- Learn
- Practice
-
05.Lesson 5: Deleting Documents in MongoDB
- Learn
- Practice
-
06.Conclusion
- Learn
John McCambridge I Curriculum Engineer
John is a Curriculum Engineer on the University team at MongoDB. Before his work as a Curriculum Engineer, he was an instructor and teaching assistant for coding boot camps at UT (Austin), and UCLA. Additionally, he worked as a QA engineer for a startup called Coder and spent five years at Apple Inc. John is a passionate software engineer and eductor who enjoys taking complex topics and making them digestible for the community.
Camden Kirkland I Technical Instructor
Cam is a Technical Instructor at MongoDB where he delivers courses for a wide variety of foundational and advanced topics on the database. Prior to MongoDB, he was a Curriculum Architect designing technical programs for web development, data analytics, and financial technologies for universities all over the country. In a past life he was a Chemist making sure your transformers didn't catch fire.
Emily Pope | Senior Curriculum Designer
Emily is a Senior Curriculum Designer at MongoDB. Prior to MongoDB, Emily worked closely with professors at MIT and Columbia to design bootcamps in full stack development and data science at Emeritus. She also worked as an instructional designer on database and computer science learning experiences at Cengage. Emily loves learning about the everchanging tech space and is passionate about making these skills accessible to a global audience.
Welcome! In this unit, you’ll learn how to replace, update, modify, and delete documents in MongoDB.
I’m Julie, a Curriculum Engineer at MongoDB, and I’ll be guiding you through this unit.
The prerequisites for this unit are a basic understanding of databases and MongoDB, and a lot of curiosity.
To work with any database, you need to know how to replace, update, and delete data. This unit will teach you how to perform these operations in MongoDB.
This unit contains video lessons as well as labs and quiz questions so that you can practice replacing, updating, and deleting documents in MongoDB.
We’ll go over common update operators and how to use the `findAndModify()` method to return documents while simultaneously updating them. We’ll also cover how to delete documents.
To successfully complete the activities in this unit, you’ll need a browser and some experience working with the command line. All labs will take place in the browser and use containerized development environments, including MongoDB command line tools.
By learning how to replace, update, and delete documents, you’ll be one step closer to fully managing your data in MongoDB. Let’s dive in!
