DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/Ruffaim/article/details/82774816

Node连接Mongoose抛出一个警告:
mongoose版本: “^5.2.12”

(node:6592) 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
//当前的URL字符串解析器被弃用然后也提供了解决方案 让你在选项里面{useNewUrlParser: true}

解决办法:

- mongoose.connect('mongodb://127.0.0.1/models');
+ mongoose.connect('mongodb://127.0.0.1/models',{ useNewUrlParser: true });
其他问题

(node:6825) DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead

使用 collection.countDocuments() 方法 替代 collection.count()
点击查看文档 collection.countDocuments()。

猜你喜欢

转载自blog.csdn.net/Ruffaim/article/details/82774816
今日推荐