- Importantmongosh Method
This page documents a
mongoshmethod. This is not the documentation for a language-specific driver such as Node.js.
For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.
For the legacy
mongoshell documentation, refer to the documentation for the corresponding MongoDB Server release:
Specifies the number of documents to return in each batch of the response from the MongoDB instance. In most cases, modifying the batch size will not affect the user or the application, as
mongoshand most drivers return results as if MongoDB returned a single batch.
batchSize()method takes the following parameter:ParameterTypeDescription
sizeintegerThe number of documents to return per batch. Do not use a batch size of
1or a negative number is analogous to using the
The following example sets the batch size for the results of a query
batchSize() method does not change the
mongosh, which, by default, iterates over the
first 20 documents.