-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Applying sort to a count query fails #3914
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
Milestone
Comments
Thanks for reporting. What version of mongoose are you using? Please tell me you upgraded from 3.8.x :) |
Yes, this is with 4.3.6. |
vkarpov15
added a commit
to mongoosejs/mquery
that referenced
this issue
Mar 1, 2016
vkarpov15
added a commit
to mongoosejs/mquery
that referenced
this issue
Mar 1, 2016
Fixed in cee7545 |
Cool, thanks. That deals with the sort issue, what's the decision on the select issue? |
No the above commits allow you to do both, see 139a90b |
Great, thank you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To generate my queries I chain on options, for example:
Now I want to add an option for
count
in my query builder, for example:However, when applying a
.sort()
to a.count()
query, no result is returned. Given that sorting has no influence on the number of matching documents, it should be ignored at the very least, certainly it shouldn't cause the query to returnundefined
as it currently does.Furthermore, as an aside to this issue, mongoose baulks if you supply a
.select()
to a.count()
with the errorUnhandled rejection Error: select cannot be used with count
. Given that select doesn't influence count either, I propose it should silently fail. Thoughts?Here's code to demonstrate the issue:
The text was updated successfully, but these errors were encountered: