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 | "abc2" | Product / SKU code |
qty | 200 | Quantity on hand |
In-range window (exclusive):
qty > 100 AND qty < 250
|---- in range ----|
--------+------------------+--------
100 250
180, 200 → inside → true
250, 300 → outside → false
80 → outside → false 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
$andnext.

