Unit 3. Connecting to a database

 

Unit 2 taught you how to set up a Node.js application with Express.js. By this point, you should feel comfortable building a basic web application with Express.js routing and templating. This unit is about taking the application you built in unit 2 and connecting it to a database. A database is where values can be stored permanently, as opposed to the data in earlier lessons, which was reset every time your application restarted.

In this book, you learn to use MongoDB, a popular database for Node.js. First, you download and install Mongo on your computer. Then you explore the MongoDB shell, a database environment similar to the Node.js REPL shell. Next, you learn some database theory behind structuring your database and the data within it. You see how models fit into the model-view-controller (MVC) architecture and how they interact with your application’s database via a package called Mongoose. Last, you explore how a database schema—an outline of your structured data—helps you relate data objects to one another.

With the goal of building a Node.js application that can store user information and display that information back on your screen, this unit covers the following topics:

sitemap