1. findOneAndUpdate、findOneAndDelete 不成功問題
`findOneAndUpdate()` and `findOneAndDelete()` without the `useFindAndModify` option set to false are deprecated.
原因: findOneAndUpdate 和 findOneAndDelete 內部使用會findAndModify驅動,此驅動即將廢除,所以提示警告。
解決辦法: 在mongoose連接時設置如下:useFindAndModify: false
可以參考官網解釋:https://mongoosejs.com/docs/deprecations.html#-findandmodify-
2. collection.count 問題
DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead
原因:collection.count 在未來版本即將廢除, 使用collection.countDocuments替代