在数据库中列出时间序列集合
您可以输出数据库中集合的列表,并通过各种属性过滤结果,包括集合类型。您可以使用此功能列出数据库中的所有时间序列集合。
步骤
要列出数据库中所有时间序列集合,请使用listCollections
命令,并使用过滤器 { type: "timeseries" }
db.runCommand( { listCollections: 1, filter: { type: "timeseries" } } )
输出
对于时间序列集合,输出包括
type: 'timeseries'
options: { timeseries: { ... } }
例如
{ 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 }