Example 1 — Sample Data
Imagine student Asha with two skill tags, and Ravi with an empty tag list. We save both in students.
db.students.insertMany([
{ _id: 1, name: "Asha", tags: ["mongo", "api"] },
{ _id: 2, name: "Ravi", tags: [] }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps two documents in students. Run find() to see them:
db.students.find() Read those arrays like this:
| Student | tags | After default unwind |
|---|---|---|
| Asha | ["mongo", "api"] | 2 documents |
| Ravi | [] | Dropped |
{ name: "Asha", tags: ["mongo", "api"] }
↓ $unwind "$tags"
{ name: "Asha", tags: "mongo" }
{ name: "Asha", tags: "api" } How It Works
- Insert once.
insertManyadds Asha and Ravi tostudents. - Array shape matters. Asha has two elements; Ravi has none.
- find() shows the full shape. Expanding happens in the pipeline, not in storage.

