mongoose db connction with node js

technical talkiess
0

 const mongoose = require('mongoose');


main().catch(err => console.log(err));

async function main() {
  await mongoose.connect('mongodb://127.0.0.1:27017/vishalkart');
console.log("Coneected Bro")
  // use `await mongoose.connect('mongodb://user:password@127.0.0.1:27017/test');` if your database has auth enabled
}

var db = mongoose.connection;
db.on('error',console.error.bind(console,'connection error:- '));
db.once('open',function(){
console.log("Ayya na bhai")
});

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)