报错 :DeprecationWarning: Mongoose: findOneAndUpdate() and findOneAndDelete() without the useFindAndModify option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#findandmodify
使用mongoose在终端会显示
DeprecationWarning: Mongoose: findOneAndUpdate() and findOneAndDelete() without the useFindAndModify option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#findandmodify

尽管不影响运行,但依然和会弹出警告
查询mongoose文档后发现,findOneAndUpdate()内部会使用findAndModify驱动,驱动在新版mongoose即将被废弃,所以弹出警告!
官方链接:https://mongoosejs.com/docs/deprecations.html
解决方案:在使用mongoose时,加上mongoose.set(‘useFindAndModify’, false)


解决Mongoose使用findOneAndUpdate及findOneAndDelete方法时出现的DeprecationWarning问题,避免使用findAndModify驱动。
268

被折叠的 条评论
为什么被折叠?



