Using Mongoose for MongoDB
Mongoose is an ODM (Object Data Modeling) library for MongoDB and Node.js. It provides a schema-based solution to model your data.
- Connects to MongoDB and defines models
- Supports schema validation and middleware
- Makes working with MongoDB easier and safer
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/dbname');