my server.js file
MongoClient.connect('mongodb://user:password@127.0.0.1:27017/QUIZ_GAME',(err,client)=>{
if(err){
return console.log('unable to connect to the MongoDb server');
}
const db =client.db('QUIZ_GAME');
console.log('connected to the MongoDb server');
in my putty terminal i had done this, to enable auth and iwas successful in doing it
use admin
db.createUser(
{
user: "admin",
pwd: "password",
roles: [ { role: "root", db: "admin" } ]
}
);
exit;
use QUIZ_GAME
db.createUser(
{
user: "tester",
pwd: "password",
roles: [{ role: 'readWrite', db:'QUIZ_GAME'}]