Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-957

Cursor does not support negative batch sizes

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.2.25
    • Affects Version/s: None
    • Component/s: None
    • None

      Our other drivers support providing a negative number for `batchSize` of a cursor, in order to return an exact number of result:

      from the PHP docs:

      If batchSize is 1 or negative, it will limit of number returned documents to the absolute value of
      batchSize, and the cursor will be closed. For example if batchSize is -10, then the server will
      return a maximum of 10 documents and as many as can fit in 4MB, then close the cursor.
      

      from Java docs:

      Limits the number of elements returned in one batch. A cursor typically fetches a batch of result
      objects and store them locally. If batchSize is positive, it represents the size of each batch of
      objects retrieved. It can be adjusted to optimize performance and limit data transfer. If batchSize is
      negative, it will limit of number objects returned, that fit within the max batch size limit (usually
      4MB), and cursor will be closed. For example if batchSize is -10, then the server will return a
      maximum of 10 documents and as many as can fit in 4MB, then close the cursor. Note that this
      feature is different from limit() in that documents must fit within a maximum size, and it removes the
      need to send a request to close the cursor server-side. The batch size can be changed even after a
      cursor is iterated, in which case the setting will apply on the next batch retrieval.
      

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: