How Mongoose helps bridge an Express/Node application to a MongoDB database
- Defining schemas for a data model using Mongoose
- Connecting an application to a database
- Managing databases using the MongoDB shell
- Pushing a database into a live environment
- Using the correct database depending on the environment, distinguishing between local and live versions of an application
In chapter 4 we ended up by moving our data out of the views and backward down the MVC path into the controllers. Ultimately, the controllers will pass data to the views, but they shouldn’t store it. Figure 5.1 recaps the data flow in an MVC pattern.
Figure 5.1. In an MVC pattern, data is held in the model, processed by a controller, and then rendered by a view.

For storing the data we’ll need a database, specifically MongoDB. So this is our next step in the process: creating a database and data model.
If you haven’t yet built the application from chapter 4, you can get the code from GitHub on the chapter-04 branch at github.com/simonholmes/getting-MEAN. In a fresh folder in terminal the following command will clone it:
$ git clone -b chapter-04 https://github.com/simonholmes/getting-MEAN.git