Q2: What is Mongoose and why use it over the native MongoDB driver?
Mongoose is an Object Data Modeling (ODM) library for Node.js. While the native driver provides direct low-level CRUD access, Mongoose adds structure by providing schema validation, type casting, middleware hooks (pre/post), dynamic virtuals, and populated document references.
Key Takeaways
Mongoose provides an ODM layer with schema enforcement.
Includes auto-casting, middleware hooks, populate references, and validation.
Knowledge Check
What is the primary role of Mongoose in a Node.js application?