Mongoose is a popular object document mapper (ODM) for Node.js that provides a natural interface for working with MongoDB documents, collections, and databases. You can think of Mongoose as a superset of MongoDB functionality that is tailored to work inside Node.js. We will use Mongoose for all the details of connecting to MongoDB, defining our model schemas, and retrieving documents. One of the strengths Mongoose shares with Express is its very lightweight, flexible, and compossible approach to database queries.
Connecting to MongoDB through Mongoose
Getting ready
To use Mongoose, we will need to install it to our Express application's package.json file:
npm install mongoose --save
Once saved to our package.json file...