March 2018
Intermediate to advanced
592 pages
13h 44m
English
With MongoDB now installed, we can move it to our mongodb-connect file and start connecting to the database. The first thing we need to do is pull something out of the library that we just installed, which is the mongodb library. What we're looking for is something called the MongoClient constructor. The MongoClient constructor lets you connect to a Mongo server and issue commands to manipulate the database. Let's go ahead and kick things off by creating a constant called MongoClient. We're going to set that equal to require, and we're going to require the library we just installed, mongodb. From that library, we're going to pull off MongoClient:
const MongoClient = require('mongodb').MongoClient; ...