I’m currently storing sensor data in MongoDB using a schema like this, as recommended here:
{
"receivedAt": ISODate, // timeField
"node_id": "string", // metaField
"type": "string",
"data": { /* sensor-specific data */ }
}
Now, I want to record certain events related to these sensors, such as a window opening or closing that have a duration (e.g., window open from 10 AM to 3 PM). However, I’m unsure about the best way to model and store these events in MongoDB alongside the time series data.
I think I should store them in a separate collection from the sensor readings.
But how can I represent events with a time range effectively in MongoDB, and efficiently query and correlate them with the continuous time series sensor data?
Maybe you have some good practices or examples to share ?
Thanks for your guidance!