In unit 2, you built web applications with Express.js. Structuring your applications to use the model-view-controller (MVC) architecture, you can now handle requests through your controllers and serve views. The third essential piece is models, with which you’ll organize data that you plan to store permanently. In this lesson, you install MongoDB, the database system that you’ll use to store persistent data. You also explore what makes document database structure in MongoDB particularly convenient for Node.js applications. By the end of the lesson, you’ll have a database set up and connected to your application.
This lesson covers
- Installing MongoDB
- Reading and entering data with in the MongoDB shell
- Connecting MongoDB to a Node.js application
Consider this
You want to start saving data from your application into a database, but you’re unsure which database to use. With Node.js, you can work with practically any common database, such as MySQL, PostgreSQL, Cassandra, Redis, and Neo4j. You can get a sense of the most supported and popular database management systems by exploring their associated packages on npm.
MongoDB, however, offers a unique style of data storage that resembles JSON—a JavaScript-friendly format that may make working with databases easier for you as you delve into saving data with Node.js for the first time.