Documents and collections
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
know the MongoDB data model and basic operations.
Planned topics
- A document is BSON (binary JSON) with an
_id; documents live in collections; collections live in databases. - Documents in one collection may differ in shape, but design a consistent shape and validate it (JSON Schema validation).
- Basic operations:
insertOne,find,updateOnewith$set,deleteOne. - Maximum document size is 16 MB (verify before recording); unbounded growth is a design smell.
Draft outline details
Demonstration
db.reviews.insertOne({ productId: 42, customerId: 7, rating: 5, text: "Great", createdAt: new Date() })
db.reviews.find({ productId: 42 }).sort({ createdAt: -1 }).limit(20)Check your understanding
What is a collection?
Show answer
A group of documents, like a table without a fixed schema.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.