Data Persistence with MongoDB
In this chapter, we will explain how MongoDB works and why it is a great starting point for a web application. We will learn how to install MongoDB locally using containers with Docker and Docker Compose and also how to use external MongoDB instances.
We will explore how to use Mongoose to interact with MongoDB, and we will migrate our application to use MongoDB instead of a JSON file, we will use tests to grant that the migration was properly done and we didn’t introduce any regression.
In summary, here are the main topics that we will explore in this chapter:
- How to set up MongoDB locally using containers with Docker and Docker Compose
- How to use an Object–relational mapping (ORM) library such as Mongoose to interact with MongoDB
- How to migrate our application to use MongoDB instead of a JSON file
- How to test any application using MongoDB
- How to use environment variables to store sensitive information and...