Time series collections
A time series collection is a special type of collection that is used to collect data measurements over a period of time.
For example, time series collection use cases can include storing Internet of Things (IoT) sensor readings, weather readings, and stock price data.
A time series collection needs to be created as such, and we cannot change a collection type into a time series one. Migrating data from a generic purpose collection to a time series one can be done using a custom script or MongoDB’s own Kafka connector for performance and stability.
To create a time series collection, we need to specify the following fields. In this context, a data point might refer to a sensor reading or the stock price at a specific point in time:
timeField
: This field is mandatory and is the field that stores the timestamp of the data point. It must be aDate()
object.metaField
: This field is optional and is used to store metadata for the data...