For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.

List Time Series Collections in a Database

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}
Rate this page

On this page