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

feat(model): make bulkWrite results include MongoDB bulk write errors as well as validation errors #15271

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

vkarpov15
Copy link
Collaborator

Fix #15265

Summary

When we return mongoose.results property from bulkWrite(), the results property doesn't currently include any MongoDB write errors that occurred. That makes it a multi-step process to determine whether a given bulk write operation succeeded or failed.

This is more consistent with how insertMany() handles errors: insertMany() already adds write errors to results. However, insertMany() has some logic where it modifies the WriteError's index, which we should consider removing because that makes the result not an instance of MongoDB's WriteError class.

Examples

@vkarpov15 vkarpov15 added this to the 8.11 milestone Feb 24, 2025
@vkarpov15 vkarpov15 merged commit 3af7b50 into 8.11 Feb 25, 2025
79 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-15265-2 branch February 25, 2025 16:22
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.

3 participants