Example 1 — Sample Data
Imagine four orders with different statuses. We save them in a collection named orders.
db.orders.insertMany([
{ _id: 1, item: "pens", status: "open" },
{ _id: 2, item: "pads", status: "archived" },
{ _id: 3, item: "clips", status: "pending" },
{ _id: 4, item: "tape", status: "cancelled" }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps four documents. Run find() to see them:
db.orders.find() Read one document like this:
| Field in MongoDB | Value (doc 1) | Plain English |
|---|---|---|
item | "pens" | Product name |
status | "open" | Order state |
How It Works
- Insert once.
insertManyadds four order documents. - status is a string. We will exclude some statuses next.
- find() shows the same shape. Ready for
$nin.

