Since that I update my mongoose package, I see this message.
DeprecationWarning: Mongoose:
findOneAndUpdate()
andfindOneAndDelete()
without theuseFindAndModify
option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#findandmodify DeprecationWarning: collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.
Oh my God !!! I use this method everything....
https://mongoosejs.com/docs/deprecations.html
After reading the documentation, I understand that the mongoose method use the Mongo Driver's findOneAndUpdate and now, we should be use Mongo Drive's findAndModify.
So I have two possibilities...
- I do nothing and in the future, the warning will go away
- I set this code after my mongoose connection
mongoose.set('useFindAndModify', false);
, the warning disappears and everyone is happy...
But if I use useFindAndModify for the moment, ow do you know when it will become useless ?
What is the best pratice for you in this situation please ?
Thank you very much !!!