MongoDB: Delete Operation

Level : Beginner
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:15:00

Lab Details

Problem Statement:

The employee collection in our MongoDB database contains documents with various details about employees, including their salary. For a particular maintenance task, we need to:

  • Delete the first matched document that has a salary of 54000.
  • Delete multiple documents from the employee collection that match the filter, i.e., City: “Agra”

Perform this through MongoDB Shell as well as MongoDB Compass.

Lab Objective:

Upon completion of this lab, you will be able to:

  • Delete the documents in a collection.
  • Use MongoDB Compass to Delete a document.
  • Use MongoDB shell to Delete a document.

Prerequisites

You should install following software on your machine:

  • MongoDB Server 7 or higher
  • MongoDB Shell
  • MongoDB Compass

In this lab, we are working with:

Database: ScholarDB

Collection: employee

Document: six documents that contain the details of employees in the form of field-value pairs.


Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this