Connecting MongoDB and Node.js

We now have a solid understanding of the most basic concepts of how MongoDB works, and it is high time we put them to good work by integrating MongoDB with Node.js. In this section, we will cover this process step-by-step, and see how we can interact with the MongoDB databases directly from within a running Node.js instance.

Setting up a basic project

Before we start, please make sure that you have Node.js and Node Package Manager (NPM) installed on your system. Refer to Chapter 1, Setting Up Your Workspace, for the steps for your particular operating system.

Once you are set, start off by creating a basic project to experiment a bit with the MongoDB instance. Create a folder somewhere and call it MongoNode. Next, open ...

Get Learning Node.js for Mobile Application Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.