Example 1 — Sample Data
Imagine two students: Asha scored 85 and Ben scored 72. We save both in a collection named students.
db.students.insertMany([
{ _id: 1, name: "Asha", score: 85 },
{ _id: 2, name: "Ben", score: 72 }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps two documents in students. Run find() to see them:
db.students.find() Read those documents like this:
| Field in MongoDB | Asha | Ben |
|---|---|---|
_id | 1 | 2 |
name | "Asha" | "Ben" |
score | 85 | 72 |
Threshold line at 80:
Ben 72 ........ 80 ........ Asha 85
|
score < 80 ?
Ben → yes
Asha → no How It Works
- Insert once.
insertManyadds two student documents tostudents. - Scores are numbers. Ready for numeric comparison with
$lt. - find() shows both rows. The next example keeps only the ones below 80.

