Chapter 5. Building a data model with MongoDB and Mongoose

This chapter covers

  • 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 ...

Get Getting MEAN with Mongo, Express, Angular, and Node now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.