Perform CRUD Operations Using mongosh

45 minutes
  • 4 Learning Objectives

About this Hands-on Lab

In this lab, students are asked to perform a set of CRUD (Create, Read, Update, and Delete) operations using the mongo shell. After completing this lab, students will have hands-on experience in performing each of the basic data manipulation operations.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a New Collection and Load Data into It

Load the data from users.csv into a new collection using the mongoimport tool.

Read the Documents

Read the documents from the collection using the db.collection.find() method.

Update a Document

Update one document using the db.collection.updateOne() method to set department = Engineering in the document with name = Betty.

Delete a Document

Delete one document with name = David using the db.collection.deleteOne() method.

Additional Resources

You are working as a DBA when you receive an email from the accounting team. They need your help to create a new MongoDB collection for the latest version of their reporting tool. The accounting team has some initial data to load, but some employees have changed departments and left the company, so it will need some updates.

Thankfully, you've just completed an awesome Mongo Deep Dive course on that showed you how to Create, Read, Update, and Delete data from a MongoDB collection using the mongosh tool. Happy to show off your new skills, you agree to help the Marketing team.

To accomplish this lab, you will need to complete the following tasks:

  • Create a new collection and Load the provided data into it.
  • Read the loaded documents to confirm they are correct.
  • Update the document where name = Betty, and set Dept = Engineering.
  • Delete the document where name = David.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?