Connecting and persisting to MongoDB
MongoDB is a popular NoSQL database that focuses on high performance and availability. MongoDB implements a document model. The document model allows data that does not have a rigid structure. Documents comprise key-value pairs.
While MongoDB is typically identified as a NoSQL database, it does provide a SQL-like syntax.
In this recipe, we'll implement a task list using MongoDB as we have done in the previous recipes in this chapter.
Getting ready
- As with the other databases in this chapter, we will be using Docker to provision a MongoDB database:
$ docker run --publish 27017:27017 --name node-mongo --detach mongo:4
- Assuming you do not have a copy of the PostgreSQL image locally, expect to see the following output while Docker downloads the image:
Unable to find image 'mongo:4' locally 4: Pulling from library/mongo 23884877105a: Pull complete bc38caa0f5b9: Pull complete 2910811b6c42: Pull complete 36505266dcc6...