Example 1 — Sample Data
Imagine four inventory items with different price and sale flags. We save them in a collection named inventory.
db.inventory.insertMany([
{ _id: 1, item: "abc", price: 1.99, sale: false, qty: 30 },
{ _id: 2, item: "jkl", price: 5.00, sale: true, qty: 10 },
{ _id: 3, item: "xyz", price: 5.00, sale: false, qty: 25 },
{ _id: 4, item: "mno", price: 1.99, sale: true, qty: 5 }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps four documents. Run find() to see them:
db.inventory.find() Read one document like this:
| Field in MongoDB | Value (doc 3) | Plain English |
|---|---|---|
price | 5.00 | Unit price |
sale | false | On sale? |
qty | 25 | Stock quantity |
How It Works
- Insert once.
insertManyadds four inventory documents. - Two key flags.
priceandsaledrive the NOR examples. - find() shows the same shape. Ready for
$nor.

