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
//The current URL string parser is deprecated Deprecated then also provides a solution for you to {useNewUrlParser: true} in options

Solution:

- mongoose.connect('mongodb://127.0.0.1/models');
+ mongoose.connect('mongodb://127.0.0.1/models',{ useNewUrlParser: true });
other problems

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

Use the collection.countDocuments() method instead of collection.count().
Click to view documents collection.countDocuments().

Related Posts