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
mongo shell methods. However, some legacy methods
are unavailable in
For the legacy
mongo shell documentation, refer to the
documentation for the corresponding MongoDB Server release:
For MongoDB API drivers, refer to the language specific MongoDB driver documentation.
These methods modify the way that the underlying query is executed.
For details on specific methods, including syntax and examples, click on the specific method to go to its reference page.
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.
Controls the number of documents MongoDB will return to the client in a single network message.
Close a cursor and free associated server resources.
Specifies the collation for the cursor returned by the
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.
Returns true if the cursor has documents and can be iterated.
Forces MongoDB to use a specific index for a query.
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
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
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
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 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.