mongoose報錯: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連接的時候在第二個參數的對象中加入
useUnifiedTopology: true
即為:
mongoose.connect(dbConfig.dbs, {
useNewUrlParser: true,
useUnifiedTopology: true //這個即是報的警告
}).then(res => {
console.log('數據庫連接成功')
})