Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 372 Bytes

section49.2.md

File metadata and controls

15 lines (13 loc) · 372 Bytes

Section 49.2: Simple way to Connect mongoDB with core Node.JS

let MongoClient = require('mongodb').MongoClient;

//connection with mongoDB
MongoClient.connect("mongodb://localhost:27017/MyDb", function (err, db) {
  //check the connection
  if(err){
    console.log("connection failed.");
  }else{
  console.log("successfully connected to mongoDB.");
  }
});