Navigation

getMore

On this page

Definition

getMore

New in version 3.2.

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

The getMore command has the following form:

{
   "getMore": <long>,
   "collection": <string>,
   "batchSize": <int>,
   "maxTimeMS": <int>
}

The command accepts the following fields:

Field Type Description
getMore long The cursor id.
collection string The name of the collection over which the cursor is operating.
batchSize positive integer Optional. The number of documents to return in the batch.
maxTimeMS non-negative integer

Optional. Specifies a time limit in milliseconds for processing operations on a cursor. If you do not specify a value for maxTimeMS, operations will not time out. A value of 0 explicitly specifies the default unbounded behavior.

MongoDB terminates operations that exceed their allotted time limit using the same mechanism as db.killOp(). MongoDB only terminates an operation at one of its designated interrupt points.

Behavior

Access Control

New in version 3.6.

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

Sessions

New in version 4.0.

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

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

Transactions

New in version 4.0.

For multi-document transactions:

  • For cursors created outside of transactions, you cannot call getMore inside a transaction.
  • For cursors created in a transaction, you cannot call getMore outside the transaction.
←   getLastError getPrevError  →