Answers for "mongodb.connect is not a function"

0

mongodb.connect is not a function

const { MongoClient } = require("mongodb");

const uri = "yourUri...";
const databaseName = "yourDBName";

MongoClient.connect(uri, { useNewUrlParser: true }, (error, client) => {
  if (error) {
    return console.log("Connection failed for some reason");
  }
  console.log("Connection established - All well");
  const db = client.db(databaseName);
});
Posted by: Guest on August-09-2021

Code answers related to "mongodb.connect is not a function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language