db.runCommand()
On this page本页内容
Definition定义
db.runCommand(command)
-
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和驱动程序之间提供了一致的接口。Parameter参数Type类型Description描述command
document or string "A database command, specified either in document form or as a string.“数据库命令,以文档形式或字符串形式指定。If specified as a string,如果指定为字符串,db.runCommand()
transforms the string into a document."db.runCommand()
会将字符串转换为文档。”To specify a time limit in milliseconds, see Terminate Running Operations.要指定以毫秒为单位的时间限制,请参阅终止正在运行的操作。
Behavior行为
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
对象更改为admin
数据库。
Response响应
The method returns a response document that contains the following fields:该方法返回一个包含以下字段的响应文档:
<command result> | command that was run.command 的结果字段。 |
ok | 1 ) or failed (0 ).1 )还是失败(0 )。 |
operationTime | operationTime returns: operationTime 返回:
afterClusterTime . afterClusterTime 。 |
$clusterTime |
|