启动mongoose的时候,有一些警告信息
(node:10568) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient const ..
(node:1920) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
修改如下后,就没有报错了。
mongoose.connect('mongodb://127.0.0.1:27017/app', { useNewUrlParser: true, useUnifiedTopology: true },function(err){
if(err){
//throw err;
console.log(err);
}else{
console.log('数据库连接成功');
}
});