Building a database with MongoDB
MongoDB is the most popular NoSQL database. It is free (open source) and document-oriented. In this recipe, we are going to install MongoDB, create a database, create a document, and insert some data to display information with Node.js using the Mongoose library.
Getting ready
First, we need to install MongoDB. In this recipe, I'm going to show you the easiest way to install it using Mac, and I'll give you some links to install it if you have Linux or Windows.
Note
From the MongoDB official documentation (https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x): "Starting in version 3.0, MongoDB only supports MacOS version 10.7 (Lion) and later on Intel x86-64."
Installing MongoDB Community Edition manually (the hard way)
This installation works for Mac and Linux:
- Download the binary files for the version you want of MongoDB from https://www.mongodb.com/download-center#community.
- Extract the files from the downloaded file; you can use the terminal and use...