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
insertMany
command in the MongoDB Shell (mongosh
).
- Operate within the
university
database.
- Ensure all three documents are successfully inserted into the
students
collection.
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
}