You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is the findOneAndUpdate method using findAndModify under the hood instead of findOneAndUpdate?
I need to pass projection settings but it's not working because findAndModifiy doesn't take such parameters, and as such it's returning the entire document.
Because mongoose's findOneAndUpdate() long predates the existence of findOneAndUpdate() in the underlying mongodb driver, and the driver's findOneAndUpdate() is just a thin wrapper around findAndModify anyway. Also, the driver's findOneAndUpdate() has several quirky semantics, especially related to the new option and the difference between new and returnNewDocument, that are troublesome for mongoose.
Yeah there's a little confusion there because every API wants to be it's own special snowflake :) Now that the mongodb driver added a findOneAndUpdate() function that has its own quirks, not quite sure yet with how to proceed on mongoose's fineOneAndUpdate()
Why is the
findOneAndUpdate
method usingfindAndModify
under the hood instead of findOneAndUpdate?I need to pass projection settings but it's not working because
findAndModifiy
doesn't take such parameters, and as such it's returning the entire document.E.g.:
The text was updated successfully, but these errors were encountered: