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 the
mongoshell and 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.
The following example sets the batch size for the results of a query
batchSize() method does not change the
output in the
mongo shell, which, by default, iterates over the
first 20 documents.