1const { MongoClient } = require("mongodb");
2
3const uri = "yourUri...";
4const databaseName = "yourDBName";
5
6MongoClient.connect(uri, { useNewUrlParser: true }, (error, client) => {
7 if (error) {
8 return console.log("Connection failed for some reason");
9 }
10 console.log("Connection established - All well");
11 const db = client.db(databaseName);
12});
13
1//Just add this line of code and client.connect and
2//-other dot functions will work
3
4var mongo = require('mongodb').MongoClient;