getMore

Definition

  • getMore

New in version 3.2.

Use in conjunction with commands that return a cursor, e.g.find and aggregate, to return subsequentbatches of documents currently pointed to by the cursor.

The getMore command has the following form:

  1. {
  2. "getMore": <long>,
  3. "collection": <string>,
  4. "batchSize": <int>,
  5. "maxTimeMS": <int>
  6. }

The command accepts the following fields:

FieldTypeDescriptiongetMorelongThe cursor id.collectionstringThe name of the collection over which the cursor is operating.batchSizepositive integerOptional. The number of documents to return in the batch.maxTimeMSnon-negative integerOptional. Specifies a time limit in milliseconds for processingoperations on a cursor. If you do not specify a value for maxTimeMS,operations will not time out. A value of 0 explicitlyspecifies the default unbounded behavior.

MongoDB terminates operations that exceed their allotted time limitusing the same mechanism as db.killOp(). MongoDB onlyterminates an operation at one of its designated interruptpoints.

Behavior

Access Control

New in version 3.6.

If authentication is turned on, you canonly issue a getMore against cursors you created.

Sessions

New in version 4.0.

For cursors created inside a session, you cannot callgetMore outside the session.

Similarly, for cursors created outside of a session, you cannot callgetMore inside a session.

Transactions

New in version 4.0.

For multi-document transactions:

  • For cursors created outside of a transaction, you cannot callgetMore inside the transaction.
  • For cursors created in a transaction, you cannot callgetMore outside the transaction.