runCommand()

Reference type:Cheat sheetFormat:Syntax + example + use case

Reference group: Indexes and aggregation

What it does

Executes a database command document.

Syntax

db.runCommand(commandDocument)

Use case

Use commands without a dedicated shell helper.

runCommand(): practical example
db.runCommand({ ping: 1 })
💡 Explanation Executes a database command document. When to use it Use commands without a dedicated shell helper.
Key Takeaways
  • Executes a database command document.
  • Typical use: Use commands without a dedicated shell helper.