Docs Menu
Docs Home
/
MongoDB Manual
/ /

Cursor Methods

Note

mongosh Methods

The methods listed on this table of contents page are mongosh methods. This is not the documentation for Node.js or other programming language specific driver methods.

In most cases, mongosh methods work the same way as the legacy mongo shell methods. However, some legacy methods are unavailable in mongosh.

For MongoDB API drivers, refer to the language specific MongoDB driver documentation.

These methods modify the way that the underlying query is executed.

Note

For details on a specific method, including syntax and examples, click on the link to the method's reference page.

Name
Description

cursor.addOption()

Adds special wire protocol flags that modify the behavior of the query.

Allows MongoDB to use temporary files on disk to store data exceeding the 100 megabyte system memory limit while processing a blocking sort operation.

Allows db.collection.find() operations against a sharded collection to return partial results, rather than an error, if one or more queried shards are unavailable.

Controls the number of documents MongoDB will return to the client in a single network message.

Close a cursor and free associated server resources.

Returns true if the cursor is closed.

Specifies the collation for the cursor returned by the db.collection.find().

Attaches a comment to the query to allow for traceability in the logs and the system.profile collection.

Modifies the cursor to return the number of documents in the result set rather than the documents themselves.

Reports on the query execution plan for a cursor.

Applies a JavaScript function for every document in a cursor.

Returns true if the cursor has documents and can be iterated.

Forces MongoDB to use a specific index for a query.

Returns true if the cursor is closed and there are no objects remaining in the batch.

Computes the total number of documents in the cursor client-side by fetching and iterating the result set.

Constrains the size of a cursor's result set.

Applies a function to each document in a cursor and collects the return values in an array.

Specifies an exclusive upper index bound for a cursor. For use with cursor.hint()

Specifies a limit in milliseconds to wait for the next query result update.

Specifies a cumulative time limit in milliseconds for processing operations on a cursor.

Specifies an inclusive lower index bound for a cursor. For use with cursor.hint()

Returns the next document in a cursor.

Instructs the server to avoid closing a cursor automatically after a period of inactivity.

Returns the number of documents left in the current cursor batch.

Configures the cursor to display results in an easy-to-read format.

Specifies a read concern for a find() operation.

Specifies a read preference to a cursor to control how the client directs queries to a replica set.

Modifies the cursor to return index keys rather than the documents.

Adds an internal storage engine ID field to each document returned by the cursor.

Returns a count of the documents in the cursor after applying skip() and limit() methods.

Returns a cursor that begins returning results only after passing or skipping a number of documents.

Returns results ordered according to a sort specification.

Marks the cursor as tailable. Only valid for cursors over capped collections.

Returns an array that contains all documents returned by the cursor.

Returns the next element in the iteration if available or else null.

Back

db.collection.watch