Documents & CollectionsBeginner
1Question 1 of 1
javascriptWhat is the document model in MongoDB and how do BSON and Collections work?
Explanation & Concept
MongoDB is a document-oriented NoSQL database that stores data as JSON-like documents formatted internally as **BSON** (Binary JSON). BSON extends JSON with additional data types such as `ObjectId`, `Date`, `Decimal128`, and raw binary buffers.
Documents are grouped into **Collections** (analogous to tables in SQL). Unlike relational tables, collections do not enforce fixed column structures; documents in the same collection can have distinct fields (polymorphic schema).
Code Example
javascript
// MongoDB document in the "users" collection
{
"_id": ObjectId("64f1a2b3c4d5e6f7a8b9c0d1"),
"name": "Jane Doe",
"email": "jane@example.com",
"tags": ["developer", "admin"],
"profile": {
"age": 29,
"github": "janedoe"
},
"created_at": ISODate("2026-01-15T10:30:00Z")
}How It Works & Key Takeaways
BSON documents allow deep nesting of objects and arrays, meaning related information (like tags and profile details) can be stored within a single document, avoiding relational joins.
Mock Test · 1 Questions · Optional
Ready for Aggregation Pipeline?
Take a quick test to evaluate yourself, or move straight to the next module.
Beginner1 questions