翻译或纠错本页面

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.

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.”

2.6 新版功能: 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.