2

The cursor.count() method's applySkipLimit boolean parameter is documented as follows:

... Specifies whether to consider the effects of the cursor.skip() and cursor.limit() methods in the count. ... Set applySkipLimit to true to consider the effect of these methods.

Meanwhile, the cursor.size() method is documented as follows:

Returns: A count of the number of documents that match the db.collection.find() query after applying any cursor.skip() and cursor.limit() methods.

This makes it sound as though cursor.count(true) and cursor.size() have identical behaviour, yet the docs for some reason neither confirm or disconfirm this explicitly, and it would seem to be an odd design decision to provide both if they behave identically. Are these two expressions, in fact, equivalent, or is there a subtle difference?

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
  • Related but not the same - the difference between `.size()` and `.count()` *without* the `applySkipLimit` parameter set to true: http://stackoverflow.com/q/11881347/1709587 – Mark Amery Jun 06 '15 at 17:23

0 Answers0