This is how we would have been storing the data...
db.readings.insertOne({
sensor: "Temp Sensor 456",
ts: new Date(),
value: 45
})
But with bucketing, we change it to...
db.readings.updateOne({
sensor: "Temp Sensor 456",
ts: new Date().setSecond(0, 0).setMinute(0),
}, {
$push: {
values: {
ts: new Date(),
value: 45
}
}
}, {upsert: true});