Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query): treat findOne(_id) as equivalent to findOne({ _id }) #12485

Merged
merged 2 commits into from Sep 30, 2022

Conversation

vkarpov15
Copy link
Collaborator

Fix #12325

Summary

#12325 pointed out that, in Mongoose 5, findOne(ObjectId) worked the same as findById(ObjectId). I don't see any reason why we shouldn't continue to support this behavior.

Examples

const Test = db.model('Test', testSchema);
const _id = new mongoose.Types.ObjectId();

const q = Test.find(_id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have also a test for findOne please?

Copy link
Collaborator

@IslandRhythms IslandRhythms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the test missing, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breaking change in findOne(ObjectId) method from mongoose 5 to mongoose 6
4 participants