Database Reference
In-Depth Information
Understanding the reporting commands
The MongoDB engine provides useful management commands, which you can use to get a
report from the current status of the databases or collections. In this section, you will learn
how to execute and use these commands.
Executing a command
In order to execute a database command, you can use the db.runCommand function in
the mongo interactive shell. To execute a command, you should pass the command name
in the first parameter of the function.
The following code is an example of using this function:
db.runCommand("dbStats")
In the preceding example, dbStats is the name of a command.
Utilizing the dbStats command
The dbStats command is useful to get statistics from a database in a JSON document.
Executing this command returns a short description about the number of collections, stor-
age size, indexes on a database, average object or file size, and so on.
To run dbStats , you can use issue the following command:
db.runCommand("dbStats")
The following screenshot shows this command's output on a working database:
Search WWH ::




Custom Search