MongoDB: db.stats() method
db.stats
The db.stats() method is used to return a document that reports on the state of the current database.
Syntax:
db.stats(scale)
Parameters:
| Name | Description | Required / Optional |
Type |
|---|---|---|---|
| scale | The scale at which to deliver results. Unless specified, this command returns all data in bytes. | Optional | number |
Example: MongoDB: db.stats() method
db.stats(1024);
Output:
> db.stats(1024);
{
"db" : "test",
"collections" : 12,
"objects" : 50796,
"avgObjSize" : 579.9073155366565,
"dataSize" : 28766,
"storageSize" : 50168,
"numExtents" : 24,
"indexes" : 13,
"indexSize" : 2283,
"fileSize" : 65536,
"nsSizeMB" : 16,
"dataFileVersion" : {
"major" : 4,
"minor" : 5
},
"extentFreeList" : {
"num" : 0,
"totalSize" : 0
},
"ok" : 1
}
Retrieve the restaurants data from here
Previous:
db.shutdownServer() method
Next:
db.version() method
