client connect is not a function node js mongodb

Solutions on MaxInterview for client connect is not a function node js mongodb by the best coders in the world

showing results for - "client connect is not a function node js mongodb"
Faye
03 Mar 2019
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
Henry
05 Mar 2016
1//Just add this line of code and client.connect and 
2//-other dot functions will work
3
4var mongo = require('mongodb').MongoClient;