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
Make behaviour of cursor.count() on client reflect server #9205
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @carlevans719 - thanks for submitting this PR! Everything here looks great! I made one small nitpick suggestion about variable naming, but functionality wise we're really close here. The approach you've implemented that sets applySkipLimit
to false
by default on the client side (to line up with what's happening on the server side) seems like the way to go, but this will break backwards compatibility for some people (especially those using Minimongo as a client side only cache who are expecting the current applySkipLimit
true
functionality). We'll review this further in our issue triage meeting today, and get back to you shortly with an update. Thanks!
packages/minimongo/cursor.js
Outdated
return this._getRawObjects({ordered: true}).length; | ||
return this._getRawObjects({ | ||
ordered: true, | ||
ignoreSkipLimit: !applySkipLimit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might make sense to just carry the applySkipLimit
variable naming throughout, instead of switching (and inverting) it to ignoreSkipLimit
. This would help simplify the code a bit and makes the logic easier to follow. Also, since applySkipLimit
is a Mongo count()
supported option, most people reviewing the code will already be familiar with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! I'll get it updated
By default cursor._getRawObjects() will set options.applySkipLimit to true, thereby honoring any skip / limit. cursor.count() on the client now calls _getRawObjects with applySkipLimit set to false by default. See #1202
Hey @hwillson. I've updated Let me know if you have any other suggestions & feel free to point me towards changelogs / documentation if it needs updating to highlight this breaking change |
Thanks for making these changes @carlevans719! We talked about this a bit more, and have decided that maintaining backwards compatibility in this case is (unfortunately) more important than correctness. By giving people an option to change things we're at least providing a workaround to the broken behavior, and we can re-visit this in the future (potentially alongside other related breaking changes). Would you be able to flip things around so that |
Makes sense @hwillson! Is the entry in |
If you could add a new heading called |
@hwillson all sorted. How does that look? |
Looks great @carlevans719 - thanks! As soon as the tests finish running, we should be all set here. LGTM! |
This PR changes the default behaviour of
cursor.count()
on the client. Previously,.count()
on the client would return the number of matching documents taking into accountskip
andlimit
. Now, it will ignore those options unless it is passedtrue
when invoked. (i.e.cursor.count(true)
). This is consistent with the way it works on the server.Issue: #1201
Introduction of feature on server-side: 258b14a & bce4df9
Previous PR (incomplete): #5023
Test app: meteor-issue-1201