选项“useFindAndModify"不支持 [英] Option "useFindAndModify" is not supported

查看:43
本文介绍了选项“useFindAndModify"不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 mongoose 连接到我的数据库,并且在我的控制台中显示选项 usefindandmodify is not supproted".我正在使用猫鼬 6.0.0

I'm trying to connect to my database using mongoose and in my console is displaying ' option usefindandmodify is not supproted '. I'm using mongoose 6.0.0

这是我的代码

  mongoose.connect(constants.CONNECTION_URL,
     { useNewUrlParser: true,
       useUnifiedTopology: true, 
       useFindAndModify: false 
     })
.then(() => app.listen(constants.PORT, () => console.log(`Server Running on Port ${constants.PORT}`)))
.catch((error) => console.log(error.message));

mongoose.Promise = global.Promise;

有人可以建议我如何摆脱它吗?如果既不是绿色也不是红色,则用白色书写.

can someone suggest me how can I get rid of that? is written with white if matters neither green nor red, white.

推荐答案

从 Mongoose 版本 6 开始,您不应将其指定为选项.会自动处理.

Starting with Mongoose version 6, you should not specify that as an option. It will be handled automatically.

对这个问题进行了解释此处.

useNewUrlParseruseUnifiedTopologyuseFindAndModifyuseCreateIndex 不再受支持.Mongoose 6 总是表现为 useNewUrlParseruseUnifiedTopologyuseCreateIndex 为真,useFindAndModify 为假.请从您的代码中删除这些选项.

useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser, useUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove these options from your code.

这篇关于选项“useFindAndModify"不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆