弃用警告:当前 URL 字符串解析器在启动服务器上已弃用
DeprecationWarning: current URL string parser is deprecated on starting server
启动 npm 时有此消息 "DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect."
因此,对于这个和其他过时的警告,我这样做了:
mongoose.connect('mongodb://localhost:27017/databasename', { useUnifiedTopology: true, useNewUrlParser: true, useCreateIndex: true }, (err, res) => {
启动 npm 时有此消息 "DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect."
因此,对于这个和其他过时的警告,我这样做了:
mongoose.connect('mongodb://localhost:27017/databasename', { useUnifiedTopology: true, useNewUrlParser: true, useCreateIndex: true }, (err, res) => {