Introduction
In this challenge, your task is to use MongoDB to populate a students collection with multiple documents. This will test your understanding of the insertMany command, which allows for the insertion of multiple documents into a collection in a single operation.
Insert Multiple Documents into the students Collection
You will populate the students collection with the following records using the insertMany command.
Tasks
Insert the following documents into the students collection:
[
{ "name": "Alice Brown", "age": 20, "major": "Engineering", "gpa": 3.6 },
{ "name": "Bob White", "age": 22, "major": "Physics", "gpa": 3.8 },
{ "name": "Charlie Green", "age": 19, "major": "Mathematics", "gpa": 3.9 }
]
Requirements
- Use the
insertManycommand in the MongoDB Shell (mongosh). - Operate within the
universitydatabase. - Ensure all three documents are successfully inserted into the
studentscollection.
Example
After completing the task, running the following command:
db.students.find();
Should output:
{
"_id": ObjectId("..."),
"name": "Alice Brown",
"age": 20,
"major": "Engineering",
"gpa": 3.6
}
{
"_id": ObjectId("..."),
"name": "Bob White",
"age": 22,
"major": "Physics",
"gpa": 3.8
}
{
"_id": ObjectId("..."),
"name": "Charlie Green",
"age": 19,
"major": "Mathematics",
"gpa": 3.9
}
Summary
In this challenge, you learned to use the insertMany command to efficiently populate a MongoDB collection with multiple documents. This skill is fundamental for managing data in MongoDB and sets the stage for more complex operations like querying and updating records.

