昨天在使用findOneAndUpdate()方法 在运行时弹出一例警告
(node:11884) DeprecationWarning: Mongoose: `findOneAndUpdate()` and `findOneAndDelete()` without the `useFindAndModify` option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#-findandmodify-
警告内容 大致意思就是不推荐使用findOneAndUpdate旧版api 并不是这个旧版的api没有用了 依旧有用 只是在使用的时候会弹警告 叫我们去使用最新版 我也懒得去文档找新方法了 但是这个警告看着碍眼 所以加代码忽略它
mongoose.set('useFindAndModify', false)
意思是 false移除koa警告
在配置mongoose全局处添加这一行代码即可