databasemongodbmongoosesql-update

mongoose difference of findOneAndUpdate and update


What is the difference between findOneAndUpdate and update?

Both accept criteria to query and doc to update.


Solution

  • Well there is the respective documentation to view for both .update() and .findAndModify() which is the root method of .findOneAndUpdate() here.

    But in the main differences there are:

    In short. One is meant to modify in "bulk" and not worry with the document content in result. And the other is meant to modify a singular document and return the document content in result.

    That's the difference.