Example 1 — Sample Data
Imagine three events stored as BSON dates in UTC. We save them in a collection named events.
db.events.insertMany([
{ _id: 1, name: "Kickoff", at: ISODate("2024-01-01T12:00:00Z") },
{ _id: 2, name: "Early UTC", at: ISODate("2024-01-01T02:00:00Z") },
{ _id: 3, name: "Wrap-up", at: ISODate("2024-01-07T12:00:00Z") }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps three documents in events. Run find() to see them:
db.events.find() Read those documents like this:
| Field in MongoDB | Example | Plain English |
|---|---|---|
_id | 1 | Event id for this lesson |
name | "Kickoff" | Event label |
at | ISODate("2024-01-01T12:00:00Z") | When it happens (UTC) |
ISO weekdays (UTC):
Kickoff 2024-01-01 noon → Monday → 1
Early UTC 2024-01-01 02:00 → Monday → 1
Wrap-up 2024-01-07 noon → Sunday → 7
Early UTC is useful later: with timezone -05:00 it becomes Sunday. How It Works
- Insert once.
insertManyadds three event documents with real BSON dates. - Use
ISODate(...). Strings alone are not valid input for$isoDayOfWeek. - find() shows the same shape. What you inserted is what you get back—ready for the next examples.

