Docs Menu
Docs Home
/
MongoDB Manual
/ /

List Time Series Collections in a Database

On this page

  • Procedure
  • Output

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.

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" }
} )

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
}

Back

Aggregations & Operators

On this page