mongoose DeprecationWarning: current URL string parser is deprecated
发布时间:2019-05-08T09:14:52:手机请访问
问题描述:
DeprecationWarning: current URL string parser is deprecated, and will be removed in a future versio n. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
解决方法:
1 2 3 4 5 6 7 8 |
var mongoose = require('mongoose'); DB_URL = 'mongodb://xxxx:27017/db_name'; /** * 连接 */ mongoose.connect(DB_URL,{ useNewUrlParser: true }); |
加入 { useNewUrlParser: true }
则不再提示 DeprecationWarning: current URL string parser is deprecated, and will be removed in a future versio
n. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
