MongoDB: Insert Document(s) in a Collection

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

Lab Details

Problem Statement:

Write a query that inserts a single document or multiple documents into the employee collection. The employee collection will have the following fields:

  • id
  • FirstName
  • LastName
  • City
  • Salary
  • Phone

If the document does not specify an _id field, MongoDB adds the _id field with an ObjectId value to the new document.

Lab Objective:

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

  • Insert a Single and Multiple Documents in Collection.
  • Use MongoDB Compass to insert the document.
  • Use MongoDB shell to insert the document.

Prerequisites

You should install following software on your machine:

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


Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ 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