Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #function
ADD COMMENT
Topic
Name
2+2 =