Example 1 — Sample Data
Imagine a tiny inventory collection. One item has quantity 250; the others do not.
db.inventory.insertMany([
{ _id: 1, item: "abc1", qty: 300 },
{ _id: 2, item: "abc2", qty: 200 },
{ _id: 3, item: "xyz1", qty: 250 },
{ _id: 4, item: "VWZ1", qty: 300 },
{ _id: 5, item: "VWZ2", qty: 180 }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps five documents. Run find() to see them:
db.inventory.find() Read one document like this:
| Field in MongoDB | Value (doc 3) | Plain English |
|---|---|---|
item | "xyz1" | Product code |
qty | 250 | Stock quantity |
How It Works
- Insert once.
insertManyadds five inventory documents. - qty is a number. We will ask “is qty not 250?” next.
- find() shows the same shape. Ready for
$ne.

