Make behaviour of cursor.count() on client reflect server #9205
Conversation
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 |
return this._getRawObjects({ordered: true}).length; | ||
return this._getRawObjects({ | ||
ordered: true, | ||
ignoreSkipLimit: !applySkipLimit |
hwillson
Oct 11, 2017
Member
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.
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.
carlevans719
Oct 11, 2017
Author
Contributor
Agreed! I'll get it updated
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