I have tried this:
const mongoClient = require('mongodb').MongoClient;
const url = 'mongodb://localhost:4000,localhost:4001/bookstore?replicaSet=myapp';
mongoClient.connect(url,(err,db)=>{
if(err){
return;
}
console.log('connected to the database');
})
But how to export the database object(db)? The db object can be get only in the callback. Could you please give me some advice?
via laoqiren
No comments:
Post a Comment