You can output a list of collections in a database and filter the results by a variety of properties, including collection type. You can use this functionality to list all time series collections in a database.
Procedure
To list all time series collections in a database, use the
listCollections
command with a filter for
{ type: "timeseries" }
:
db.runCommand( {
listCollections: 1,
filter: { type: "timeseries" }
} )
Output
For time series collections, the output includes:
type: 'timeseries'
options: { timeseries: { ... } }
For example:
{
cursor: {
id: Long("0"),
ns: 'test.$cmd.listCollections',
firstBatch: [
{
name: 'weather',
type: 'timeseries',
options: {
timeseries: {
timeField: 'timestamp',
metaField: 'metadata',
granularity: 'hours',
bucketMaxSpanSeconds: 2592000
}
},
info: { readOnly: false }
}
]
},
ok: 1
}