Note: Just take a quick overview of this for now — we will learn it thoroughly throughout the notes.
🧩 What is Mongoose?
Mongoose is an ODM (Object Data Modeling) library for MongoDB and Node.js.
It helps developers interact with MongoDB by using JavaScript objects and adding structure to data.
🧠 In Simple Terms
Without Mongoose:
- MongoDB stores documents without strict rules (schema-less)
With Mongoose:
- You define schemas (structure and rules)
- You create models to interact with the database
- You get validation, defaults, and query helpers
🔧 What Mongoose Does
- Defines schemas (data structure)
- Creates models (for interacting with collections)
- Adds validation
- Simplifies CRUD operations (Create, Read, Update, Delete)
- Enables middleware (hooks like
pre-save, post-remove)