Definition定义
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
Note
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.所有MongoDB Atlas集群都支持此命令。有关Atlas支持所有命令的信息,请参阅不支持的命令。
- MongoDB Enterprise
: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本 - MongoDB Community
: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.runCommand(
{
getMore: <long>,
collection: <string>,
batchSize: <int>,
maxTimeMS: <int>,
comment: <any>
}
)Command Fields命令字段
The command accepts the following fields:该命令接受以下字段:
getMore | long | The cursor identifier. |
collection | ||
batchSize | positive integer |
|
maxTimeMS |
| |
comment |
|
Output输出
The command returns a document that contains the cursor information as well as the next batch.该命令返回一个包含游标信息以及下一批的文档。
For example, running 例如,在分片集群上通过getMore on a cursor created by a find operation on a sharded cluster returns a document similar to this output:find操作创建的游标上运行getMore会返回类似于以下输出的文档:
{
"cursor" : {
"id" : Long("678960441858272731"),
"ns" : "test.contacts",
"nextBatch" : [
{
"_id" : ObjectId("5e8e501e1a32d227f9085857"),
"zipcode" : "220000"
}
],
"partialResultsReturned" : true,
"postBatchResumeToken": "< Resume Token >"
},
"ok" : 1,
"operationTime" : Timestamp(1586385239, 2),
"$clusterTime" : {
"clusterTime" : Timestamp(1586385239, 2),
"signature" : {
"hash" : BinData(0,"lLjejeW6AQGReR9x1PD8xU+tP+A="),
"keyId" : Long("6813467763969884181")
}
}
}
cursor |
|
"ok" | 1) or failed (0).1)还是失败(0)。 |
In addition to these fields, the 除了这些字段外,db.runCommand() response includes the following information for replica sets and sharded clusters:db.runCommand()响应还包括副本集和分片集群的以下信息:
$clusterTimeoperationTime
See db.runCommand() Response for details.有关详细信息,请参阅db.runCommand()响应。
Behavior行为
Access Control访问控制
If authentication is enabled, you can only run 如果启用了身份验证,则只能对创建的游标运行getMore against cursors you created.getMore。
Sessions会话
For cursors created inside a session, you cannot call 对于在会话内创建的游标,不能在会话外调用getMore outside the session.getMore。
Similarly, for cursors created outside of a session, you cannot call 同样,对于在会话外创建的游标,您不能在会话内调用getMore inside a session.getMore。
Transactions事务
Errors错误
Starting in MongoDB 8.2, the cursor identifier must match the name of the cursor that operates on the specified 从MongoDB 8.2开始,游标标识符必须与操作指定collection. collection的游标名称匹配。If the 如果collection does not have a cursor with the specified cursor identifier, getMore returns an error.collection中没有具有指定游标标识符的游标,getMore将返回错误。
Slow Queries慢查询
Starting in MongoDB 5.1, when a 从MongoDB 5.1开始,当getMore command is logged as a slow query, the queryHash and planCacheKey fields are added to the slow query log message and the profiler log message.getMore命令作为慢速查询记录时,queryHash和planCacheKey字段将添加到慢速查询日志消息和分析器日志消息中。
Starting in MongoDB 8.0, the existing 从MongoDB 8.0开始,现有的queryHash field is duplicated in a new field named planCacheShapeHash. If you're using an earlier MongoDB version, you'll only see the queryHash field. queryHash字段被复制到一个名为planCacheShapeHash的新字段中。如果你使用的是早期的MongoDB版本,你只会看到queryHash字段。Future MongoDB versions will remove the deprecated 未来的MongoDB版本将删除弃用的queryHash field, and you'll need to use the planCacheShapeHash field instead.queryHash字段,您将需要使用planCacheShapeHash字段。