关于node.js连接mongoDb数据库报错问题 { useUnifiedTopology: true }
·
报错如下
(node:11972) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

今天连接mongoDb数据库是一直报上面的错误,后来查了一下,翻译如下:
弃用警告:当前服务器发现和监视引擎已弃用,将在将来的版本中删除。要使用新的服务器发现和监视引擎,请将选项{useUnifiedTopology:true}传递给mongoclient构造函数。
意思是说要将**{useUnifiedTopology:true}**加入到连接数据库的函数中,方法如下;

加上之后就可以正常连接了。

更多推荐
所有评论(0)