使用mongoose版本(4.11.0)连接到Mongo DB [英] connecting to Mongo DB with mongoose version (4.11.0)
问题描述
我正在尝试使用新的猫鼬版本(4.11.0)访问Mongo数据库:" mongoose.connect(" mongodb://localhost/restful_blog_app); "
I am trying to access the Mongo DB with the new mongoose version (4.11.0): "mongoose.connect("mongodb://localhost/restful_blog_app");"
我收到以下消息:
open()
在猫鼬> = 4.11.0中已弃用,请改用openUri()
或
如果使用connect()
或createConnection()
I got the following message:
open()
is deprecated in mongoose >= 4.11.0, use openUri()
instead, or
set the useMongoClient
option if using connect()
or createConnection()
我尝试了以下修复程序:
" mongoose.connect(" mongodb://localhost/restful_blog_app,{useMongoClient:true}); "
I tried the following fix:
"mongoose.connect("mongodb://localhost/restful_blog_app", {useMongoClient: true});"
结论:该消息消失了,但是我刚刚创建的DB没有数据!
Conclusion: That message has disappeared, but the DB I just created has no data!
请帮助!
推荐答案
最简单的解决方法;
"npm remove mongoose"
然后
"npm install mongoose@4.10.8 --save"
问题解决了.
升级并非总是最好的选择.
Upgrading is not always the best option.
帮助它会为您提供帮助.
Help it will help you.
谢谢
这篇关于使用mongoose版本(4.11.0)连接到Mongo DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!