getCollectionInfos() – Return collection information for all collections command
Returns statistics for all collections in the current database.
Syntax diagram
Command parameters
None or, optionally, a JSON query to get specific collection information.
Output
Values for the following properties are returned:
- readOnly
- Retrieves whether the connection object is in read-only mode.
- capped
- Identifies whether a collection is capped.
- ns
- The namespace of a specified
collection:
"<JSON namespace>": "<name>.<collection name>" - count
- Total number of rows in all collections.
- size
- Total size of the stored documents in all collections.
- aveObjSize
- Average size of the stored documents, in kilobytes (KB).
- nindexes
- Number of Indexes, including the primary index.
- indexSizes
- List of indexes and their sizes on all
collections.
indexSizes[{"<indexname>": <size>}]
Examples
The following example shows the command syntax for returning statistics for all collections in
the current database:
db.getCollectionInfos()The following example shows the
syntax of values returned from running the getCollectionInfos
command:[
{
"name" : "mycoll",
"info" : {
"readOnly" : false,
"isCapped" : false
},
"ns" : "TEST.mycoll",
"count" : 8,
"size" : 909312.0,
"avgObjSize" : 111.0,
"nindexes" : 1,
"indexSizes" : [{"_id_":-1}]
},
{
"name" : "newC",
"info" : {
"readOnly" : false,
"isCapped" : true
},
"ns" : "TEST.newC",
"count" : 0,
"size" : -1,
"avgObjSize" : 0.0,
"nindexes" : 1,
"indexSizes" : [{"_id_":-1}] }
] The following example shows the command syntax for returning only information about the
collection,
mycoll:db.getCollectionInfos({ “name” : “mycoll” })The following example shows the syntax of values returned from running the
getCollectionInfos command on the collection,
mycoll:{
"name" : "mycoll",
"info" : {
"readOnly" : false,
"isCapped" : false
},
"ns" : "TEST.mycoll",
"count" : 8,
"size" : 909312.0,
"avgObjSize" : 111.0,
"nindexes" : 1,
"indexSizes" : [{"_id_":-1}]
} 