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(types): support findOneAndReplace with rawResult #12062

Conversation

lantw44
Copy link
Contributor

@lantw44 lantw44 commented Jul 7, 2022

Summary

Both findOneAndReplace and findOneAndUpdate support the rawResult
option, which changes the return type to include more information from
the MongoDB driver. Add an overload for findOneAndReplace to support
rawResult in a way similar to findOneAndUpdate.

Examples

Allow code like this to compile:

const result = await models.OCPISession.findOneAndReplace(
  { uid },
  { uid, field: value },
  { session, rawResult: true, upsert: true, new: true },
).exec();
console.log(result.lastErrorObject?.upserted);

Both findOneAndReplace and findOneAndUpdate support the rawResult
option, which changes the return type to include more information from
the MongoDB driver. Add an overload for findOneAndReplace to support
rawResult in a way similar to findOneAndUpdate.
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

Thanks 👍 I'll double check whether our benchmarks show performance regressions or not in master, because this is branched off of a commit that had a performance issue.

@vkarpov15 vkarpov15 added this to the 6.4.4 milestone Jul 8, 2022
@vkarpov15 vkarpov15 merged commit 51ea808 into Automattic:master Jul 8, 2022
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.

None yet

2 participants