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

types(query): returnDocument type safety #12906

Merged
merged 2 commits into from
Jan 13, 2023
Merged

Conversation

AbdelrahmanHafez
Copy link
Collaborator

This PR sets type safety returnDocument type as 'before' | 'after' instead of accepting any string.

@AbdelrahmanHafez AbdelrahmanHafez added the typescript Types or Types-test related issue / Pull Request label Jan 13, 2023
@AbdelrahmanHafez AbdelrahmanHafez added this to the 6.8.4 milestone Jan 13, 2023
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

LGTM

though i have just noticed (not related to this PR) that the JSDoc documentation does not list returnDocument as "deprecated" or in relation to new, but the TSDoc says it is deprecated (reference Model.findOneAndUpdate (same for findOneAndReplace and findByIdAndUpdate))

@AbdelrahmanHafez AbdelrahmanHafez merged commit 78b3b54 into master Jan 13, 2023
@AbdelrahmanHafez AbdelrahmanHafez deleted the update-types branch January 13, 2023 14:49
@AbdelrahmanHafez
Copy link
Collaborator Author

@hasezoey
I think you meant returnOriginal* is deprecated, returnDocument is the modern way of returning the document before/after the update AFAIK.
Am I understanding this correctly?

@hasezoey
Copy link
Collaborator

I think you meant returnOriginal* is deprecated, returnDocument is the modern way of returning the document before/after the update AFAIK.
Am I understanding this correctly?

yes, i misread, thanks for clarifying

@vkarpov15
Copy link
Collaborator

Just to clarify. returnOriginal is deprecated, as well as new. returnDocument is the new recommended approach for specifying whether findOneAndUpdate() returns the document as it was before changes were applied, or after changes were applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants