iankiku
8/24/2018 - 6:15 AM

From http://mongodb.github.io/node-mongodb-native/3.1/quick-start/quick-start/

// npm install mongodb --save   //in project folder

const MongoClient = require('mongodb').MongoClient;
const assert = require('assert');

// Connection URL
const url = 'mongodb://localhost:27017';

// Database Name
const dbName = 'myproject';

// Use connect method to connect to the server
MongoClient.connect(url, function(err, client) {
  assert.equal(null, err);
  console.log("Connected successfully to server");

  const db = client.db(dbName);

  client.close();
});