Preparing your workspace
MongoDB is a document-oriented NoSQL database that stores data as flexible BSON documents inside collections.
Unlike relational databases that mainly organize data into tables and rows, MongoDB stores records as documents. Documents look similar to JSON objects and can contain nested objects and arrays. Related documents are grouped inside collections. MongoDB is useful when application data naturally fits document structures and when teams want flexible schemas and easy horizontal scaling options. Even though documents are flexible, good MongoDB design still requires clear data modeling rules.
A learning platform can store a course document containing its title, description, instructor information, and lesson summaries in one structured document when that model fits the application's access patterns.
const course = {
title: "React Fundamentals",
level: "Beginner",
published: true,
lessons: [
{ title: "Components", duration: 20 },
{ title: "Props", duration: 25 }
]
};
console.log(course);The JavaScript object represents the kind of document that can be stored in MongoDB.