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
{{ message }}
Repository navigation
findOne({ someField: undefined }) and findOne({ _id: undefined }) do NOT behave like findOne({}) #15551
According to the documentation, both findOne({ _id: undefined }) and findOne({ someField: undefined }) should behave like findOne({}) and return the first document.
But in practice, both return null and only findOne({}) returns a document.
So the documentation should be updated to reflect current Mongoose behavior.
Activity
domharrington commentedon Jul 30, 2025
This might be related to this change in MongoDB v8: https://www.mongodb.com/docs/manual/release-notes/8.0-compatibility/#queries-for-null-don-t-match-undefined-fields
You can also use this
omitUndefined()helper to strip anyundefinedquery values.fix(model): remove unnecessary conversion of undefined -> null in fin…
Merge pull request #15566 from Automattic/vkarpov15/gh-15551