I am using mongoose findOneAndUpdate
but still getting the error,
DeprecationWarning: collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.
But I am not even using findAndModify
, why is it converting my query to findAndModify
?
Kenil Vasani
You need to set the option in the query
useFindAndModify
tofalse
, as mentioned in the docs.(search keyword Currently supported options are)
and if you see the definition file of mongoose, where mentioned that it calls findAndModify update command.
Recently updated in the mongoose docs (Click here) for these deprecation where mentioned:
There are three ways or more by which you can avoid the use of
FindAndModify
: