Example 1 — Sample Data
Imagine five inventory items. Each document has an item code and a quantity. We save them in a collection named inventory.
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 in inventory. Run find() to see them:
db.inventory.find() Read those documents like this:
| Field in MongoDB | Example | Plain English |
|---|---|---|
_id | 1 … 5 | Document id for this lesson |
item | "abc1" | Product / SKU code |
qty | 250 | Quantity on hand |
Threshold: qty ≥ 250
|---- pass (≥) ----|
--------+------------------+--------
250
180, 200 → false
250, 300 → true ← 250 is included How It Works
- Insert once.
insertManyadds five inventory documents. - MongoDB stores fields as written. Each row keeps
itemandqtyas plain values. - find() shows the same shape. What you inserted is what you get back—ready for
$gtenext.

