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

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()。

你可能感兴趣的:(DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version)