Tutorial by Examples

MongoClient.connect('mongodb://localhost:27017/myNewDB',function (err,db) { if(err) console.log("Unable to connect DB. Error: " + err) else console.log('Connected to DB'); db.close(); }); myNewDB is DB name, if it does not exists in database then it...
var 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{ ...

Page 1 of 1