Example 1 — Sample Data
Imagine two students. Each has a name and an array of quiz scores out of 10. We save them in a collection named quizzes.
db.quizzes.insertMany([
{ _id: 1, name: "Ada", scores: [8, 7, 9] },
{ _id: 2, name: "Grace", scores: [6, 8, 7] }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps two documents in quizzes. Run find() to see them:
db.quizzes.find() Read one document like this:
| Field in MongoDB | Value (Ada) | Plain English |
|---|---|---|
_id | 1 | Document id |
name | "Ada" | Student name |
scores | [8, 7, 9] | Quiz scores out of 10 |
How It Works
- Insert once.
insertManyadds two student documents toquizzes. - scores is an array. Each number is one quiz result—ready for
$map. - find() shows the same shape. What you inserted is what you get back.

