Example 1 — Sample Data
Imagine three temperature sensors. Values include decimals and one negative reading so we can see toward-zero behavior.
db.readings.insertMany([
{ _id: 1, sensor: "Temp-A", value: 21.578 },
{ _id: 2, sensor: "Temp-B", value: 18.942 },
{ _id: 3, sensor: "Temp-C", value: -3.789 }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps three documents in readings. Run find() to see them:
db.readings.find() Read each document like this:
| Field in MongoDB | Example | Plain English |
|---|---|---|
_id | 1 | Document id (row number for this lesson) |
sensor | "Temp-A" | Sensor name |
value | 21.578 | Raw reading (extra decimal digits) |
How It Works
- Insert once.
insertManyadds three reading documents toreadings. - Values stay precise. MongoDB stores the full decimals until you truncate them.
- find() shows the same shape. What you inserted is what you get back—ready for
$truncnext.

