I have created one sample application for connection of mongodb and nodejs. I got error like MongoError: there are no users authenticated
after that I have added username and password to the mongodb connection string like "mongodb://root:root@localhost:27017/marankings"
so authentication eror has gone and it gives me new error like
Buffer.from('n=', 'utf8'), ^
TypeError: utf8 is not a function at Function.from (native) at Function.from (native)
Please guide me on this , I am stuck here.
This is my code
connectToServer: function(callback) {
MongoClient.connect("mongodb://root:root@localhost:27017/marankings", function(err, db) {
//db = db;
var dbcon=db.db("marankings");
console.log("this is connected db"+_db);
var myobj = { name: "Akshay Champavat", address: "akshay@gmail.com" };
dbcon.collection("users").insertOne(myobj, function(err, res) {
if (err) throw err;
console.log("1 document inserted");
dbcon.close();
});
return callback(err);
});
},
Please help , Thanks in advance !!!