Provides a helper to run specified database commands. 提供运行指定数据库命令的帮助程序。This is the preferred method to issue database commands, as it provides a consistent interface between the shell and drivers.这是发出数据库命令的首选方法,因为它在shell和驱动程序之间提供了一致的接口。
db.runCommand() runs the command in the context of the current database. 在当前数据库的上下文中运行命令。Some commands are only applicable in the context of the admin database, and you must change your db object to before running these commands or use db.adminCommand().有些命令仅适用于admin数据库的上下文,在运行这些命令或使用db.adminCommand()之前,必须更改db对象。
Response回答
The method returns a response document that contains the following fields:该方法返回包含以下字段的响应文档:
Field字段
Description描述
<command result>
Result fields specific to the command that was run.特定于运行的命令的结果字段。
ok
A number that indicates whether the command has succeeded (1) or failed (0). 指示命令是成功(1)还是失败(0)的数字。
operationTime
The logical time of the operation. MongoDB uses the logical time to order operations. Only for replica sets and sharded clusters.操作的逻辑时间。MongoDB使用逻辑时间对操作进行排序。仅适用于副本集和分片群集。
If the command does not generate an oplog entry, e.g. a read operation, then the operation does not advance the logical clock. 如果命令没有生成oplog条目,例如读取操作,则该操作不会提前逻辑时钟。In this case, operationTime returns:在这种情况下,operationTime返回:
For read concern "local", the timestamp of the most recent entry in the oplog.对于读取关注点"local",oplog中最新条目的时间戳。
A document that returns the signed cluster time. 返回签名群集时间的文档。Cluster time is a logical time used for ordering of operations. 群集时间是用于排序操作的逻辑时间。Only for replica sets and sharded clusters. 仅适用于副本集和分片群集。For internal use only.仅供内部使用。
The document contains the following fields:该文档包含以下字段:
clusterTime: timestamp of the highest known cluster time for the member.:成员的最高已知群集时间的时间戳。
signature: a document that contains the hash of the cluster time and the id of the key used to sign the cluster time.:一个包含集群时间哈希和用于签名集群时间的密钥id的文档。