选项“useFindAndModify"不支持 [英] Option "useFindAndModify" is not supported
问题描述
我正在尝试使用 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.
useNewUrlParser
、useUnifiedTopology
、useFindAndModify
和 useCreateIndex
不再受支持.Mongoose 6 总是表现为 useNewUrlParser
、useUnifiedTopology
和 useCreateIndex
为真,useFindAndModify
为假.请从您的代码中删除这些选项.
useNewUrlParser
,useUnifiedTopology
,useFindAndModify
, anduseCreateIndex
are no longer supported options. Mongoose 6 always behaves as ifuseNewUrlParser
,useUnifiedTopology
, anduseCreateIndex
are true, anduseFindAndModify
is false. Please remove these options from your code.
这篇关于选项“useFindAndModify"不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!