cursor.batchSize()
On this page本页内容
Definition定义
cursor.batchSize(size)
- Important
mongosh Method
This page documents a
mongosh
method. 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.
Specifies the number of documents to return in each batch of the response from the MongoDB instance.指定在MongoDB实例的每一批响应中要返回的文档数。In most cases, modifying the batch size will not affect the user or the application, as在大多数情况下,修改批处理大小不会影响用户或应用程序,因为mongosh
and most drivers return results as if MongoDB returned a single batch.mongosh
和大多数驱动程序返回的结果就像MongoDB返回的是单个批处理一样。ThebatchSize()
method takes the following parameter:batchSize()
方法采用以下参数:Parameter参数Type类型Description描述size
integer The number of documents to return per batch.每批要返回的文档数。
Example实例
The following example sets the batch size for the results of a query (i.e. 以下示例将查询(例如find()
) to 10
. find()
)结果的批处理大小设置为10
。The batchSize()
method does not change the output in mongosh
, which, by default, iterates over the first 20 documents.batchSize()
方法不会更改mongosh
中的输出,默认情况下,mongosh
会对前20个文档进行迭代。
db.inventory.find().batchSize(10)