文档菜单
文档首页
/
MongoDB 手册
/ /

在数据库中列出时间序列集合

本页内容

  • 步骤
  • 输出

您可以输出数据库中集合的列表,并通过各种属性过滤结果,包括集合类型。您可以使用此功能列出数据库中的所有时间序列集合。

要列出数据库中所有时间序列集合,请使用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
}

返回

聚合和操作符

本页内容