Home > Mobile >  How to know if a time series collection is successfully created on MongoDB?
How to know if a time series collection is successfully created on MongoDB?

Time:01-26

        await conn.db("db_ts").collection("col_ts", {
          timeseries: {
            timeField: "timestamp",
            metaField: "metadata",
          },
        });

After this collection is created and data written to it, I have no indicator that it is a time series collection.

I know that on Atlas if I create a time series collection using the UI, there will be an icon and it would explicitly say time series collection. But there isn't any such indicators when I create the col_ts.

CodePudding user response:

You can use the command db.getCollectionInfos().

For a time series collection, the type field will have a value timeseries

[
  ...
  {
    name: 'col_ts',
    type: 'timeseries',
    options: { timeseries: [Object] },
    info: { readOnly: false }
  }
  ...
]
  • Related