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(query): add options parameter to Query.prototype.sort() #14375

Merged
merged 1 commit into from Feb 27, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #14365

Summary

Right now, sort(null) is a no-op. There's no good way to unset the current sort option other than delete query.getOptions().sort, which works but looks a bit janky. This PR adds q.sort(null, { override: true }), the override option lets you explicitly override the current sort.

Examples

@FaizBShah
Copy link
Contributor

This looks good to me. Can we also add the documentation for the 2nd parameter override in setOptions() function in this PR? (Or is that out of scope of this PR?)

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.

Looks good to me.
As for the "condition boolean checks instead of truthy" issue, i am impartial, as i think both methods are being used in mongoose and not anything specific is set to be used.

@vkarpov15 vkarpov15 merged commit e8ce022 into 8.3 Feb 27, 2024
39 checks passed
@vkarpov15 vkarpov15 added this to the 8.3 milestone Feb 27, 2024
@hasezoey hasezoey deleted the vkarpov15/gh-14365 branch February 28, 2024 10:44
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

4 participants