db.createCollection(
"weather27h1",
{
timeseries:
{
timeField: "timestamp",
metaField: "metadata",
granularity: "hours"
}
,
expireAfterSeconds: 86400
}
)
db.weather27h1.insertMany( [
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-10T00:00:00.000Z"),
"temp": 12
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-10T04:00:00.000Z"),
"temp": 11
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-10T08:00:00.000Z"),
"temp": 11
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-10T12:00:00.000Z"),
"temp": 12
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-10T16:00:00.000Z"),
"temp": 16
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-17T20:00:00.000Z"),
"temp": 15
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-19T00:00:00.000Z"),
"temp": 13
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-19T04:00:00.000Z"),
"temp": 12
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-19T08:00:00.000Z"),
"temp": 11
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-19T12:00:00.000Z"),
"temp": 12
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-19T16:00:00.000Z"),
"temp": 17
},
{
"metadata": \{ "sensorId": 5578, "type": "temperature" }
,
"timestamp": ISODate("2023-08-19T20:00:00.000Z"),
"temp": 12
}
] )