40
loading...
This website collects cookies to deliver better user experience
{ ts: 2021-07-10T00:00:03.000Z,
metadata: { sensorId: 31096, type: 'windspeed' },
value: 32.53987084180961 }
db.createCollection("windsensors", { timeseries: { timeField: "ts", metaField: "metadata", granularity: "seconds" } } )
db.windsensors.insertMany([
{"metadata":{"sensorId":52396,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:02Z"),"value":18.263742590570686},
{"metadata":{"sensorId":31096,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:03Z"),"value":32.53987084180961},
{"metadata":{"sensorId":52396,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:03Z"),"value":18.106480571706808},
{"metadata":{"sensorId":62088,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:04Z"),"value":20.306831899199864},
{"metadata":{"sensorId":31096,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:04Z"),"value":0.6909954039798452},
{"metadata":{"sensorId":62088,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:06Z"),"value":0.031065898581725086},
{"metadata":{"sensorId":27470,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:07Z"),"value":6.878726412679837},
{"metadata":{"sensorId":31096,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:07Z"),"value":3.9089926192773534},
{"metadata":{"sensorId":52396,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:07Z"),"value":28.03679268099916},
{"metadata":{"sensorId":52396,"type":"windspeed"},"ts":ISODate("2021-07-10T00:00:07Z"),"value":1.0575968433736358}
])
db.windsensors.find()
{ ts: 2021-07-10T00:00:02.000Z,
metadata: { sensorId: 52396, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a19"),
value: 18.263742590570686 }
{ ts: 2021-07-10T00:00:03.000Z,
metadata: { sensorId: 52396, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a1b"),
value: 18.106480571706808 }
{ ts: 2021-07-10T00:00:07.000Z,
metadata: { sensorId: 52396, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a21"),
value: 28.03679268099916 }
{ ts: 2021-07-10T00:00:07.000Z,
metadata: { sensorId: 52396, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a22"),
value: 1.0575968433736358 }
{ ts: 2021-07-10T00:00:03.000Z,
metadata: { sensorId: 31096, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a1a"),
value: 32.53987084180961 }
{ ts: 2021-07-10T00:00:04.000Z,
metadata: { sensorId: 31096, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a1d"),
value: 0.6909954039798452 }
{ ts: 2021-07-10T00:00:07.000Z,
metadata: { sensorId: 31096, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a20"),
value: 3.9089926192773534 }
{ ts: 2021-07-10T00:00:04.000Z,
metadata: { sensorId: 62088, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a1c"),
value: 20.306831899199864 }
{ ts: 2021-07-10T00:00:06.000Z,
metadata: { sensorId: 62088, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a1e"),
value: 0.031065898581725086 }
{ ts: 2021-07-10T00:00:07.000Z,
metadata: { sensorId: 27470, type: 'windspeed' },
_id: ObjectId("60f3350afbb696c9ace09a1f"),
value: 6.878726412679837 }
db.getCollection('system.views').find()
{ _id: 'mytsdemo.windsensors',
viewOn: 'system.buckets.windsensors',
pipeline:
[ { '$_internalUnpackBucket':
{ timeField: 'ts',
metaField: 'metadata',
bucketMaxSpanSeconds: 3600,
exclude: [] } } ] }
db.getCollection('system.buckets.windsensors').findOne()
{ _id: ObjectId("60e8e30043c83ccb1994f6d5"),
control:
{ version: 1,
min:
{ ts: 2021-07-10T00:00:00.000Z,
value: 1.0575968433736358,
_id: ObjectId("60f3350afbb696c9ace09a19") },
max:
{ ts: 2021-07-10T00:00:07.000Z,
value: 28.03679268099916,
_id: ObjectId("60f3350afbb696c9ace09a22") } },
meta: { sensorId: 52396, type: 'windspeed' },
data:
{ _id:
{ '0': ObjectId("60f3350afbb696c9ace09a19"),
'1': ObjectId("60f3350afbb696c9ace09a1b"),
'2': ObjectId("60f3350afbb696c9ace09a21"),
'3': ObjectId("60f3350afbb696c9ace09a22") },
value:
{ '0': 18.263742590570686,
'1': 18.106480571706808,
'2': 28.03679268099916,
'3': 1.0575968433736358 },
ts:
{ '0': 2021-07-10T00:00:02.000Z,
'1': 2021-07-10T00:00:03.000Z,
'2': 2021-07-10T00:00:07.000Z,
'3': 2021-07-10T00:00:07.000Z } } }
control.min holds the bucket’s lower bound timestamp value which depends on the chosen granularity, additionally the lowest value measured in this bucket and the ObjectId referring to the first entry stored in this document’s bucket.
control.max holds the most recent timestamp value stored in this bucket, additionally the highest value measured in this bucket and the ObjectId referring to the last entry stored in this document’s bucket so far.
{
_id: ObjectId("60f3350afbb696c9ace09a19"),
ts: 2021-07-10T00:00:02.000Z,
value: 18.263742590570686,
meta: { sensorId: 52396, type: 'windspeed' }
}
{ _id: ObjectId("60e8e30043c83ccb1994f6d6"),
control:
{ version: 1,
min:
{ ts: 2021-07-10T00:00:00.000Z,
value: 0.6909954039798452,
_id: ObjectId("60f3350afbb696c9ace09a1a") },
max:
{ ts: 2021-07-10T00:00:07.000Z,
value: 32.53987084180961,
_id: ObjectId("60f3350afbb696c9ace09a20") } },
meta: { sensorId: 31096, type: 'windspeed' },
data:
{ _id:
{ '0': ObjectId("60f3350afbb696c9ace09a1a"),
'1': ObjectId("60f3350afbb696c9ace09a1d"),
'2': ObjectId("60f3350afbb696c9ace09a20") },
value:
{ '0': 32.53987084180961,
'1': 0.6909954039798452,
'2': 3.9089926192773534 },
ts:
{ '0': 2021-07-10T00:00:03.000Z,
'1': 2021-07-10T00:00:04.000Z,
'2': 2021-07-10T00:00:07.000Z } } }
{ _id: ObjectId("60e8e30043c83ccb1994f6d7"),
control:
{ version: 1,
min:
{ ts: 2021-07-10T00:00:00.000Z,
value: 0.031065898581725086,
_id: ObjectId("60f3350afbb696c9ace09a1c") },
max:
{ ts: 2021-07-10T00:00:06.000Z,
value: 20.306831899199864,
_id: ObjectId("60f3350afbb696c9ace09a1e") } },
meta: { sensorId: 62088, type: 'windspeed' },
data:
{ _id:
{ '0': ObjectId("60f3350afbb696c9ace09a1c"),
'1': ObjectId("60f3350afbb696c9ace09a1e") },
value: { '0': 20.306831899199864, '1': 0.031065898581725086 },
ts: { '0': 2021-07-10T00:00:04.000Z, '1': 2021-07-10T00:00:06.000Z } } }
{ _id: ObjectId("60e8e30043c83ccb1994f6d8"),
control:
{ version: 1,
min:
{ ts: 2021-07-10T00:00:00.000Z,
value: 6.878726412679837,
_id: ObjectId("60f3350afbb696c9ace09a1f") },
max:
{ ts: 2021-07-10T00:00:07.000Z,
value: 6.878726412679837,
_id: ObjectId("60f3350afbb696c9ace09a1f") } },
meta: { sensorId: 27470, type: 'windspeed' },
data:
{ _id: { '0': ObjectId("60f3350afbb696c9ace09a1f") },
value: { '0': 6.878726412679837 },
ts: { '0': 2021-07-10T00:00:07.000Z } } }
{ _id: ObjectId("60e8e30043c83ccb19952b3f"),
control:
{ version: 1,
min:
{ _id: ObjectId("60f2ef27f161e04419383dbb"),
ts: 2021-07-10T00:00:00.000Z,
value: 0.13698301036640723 },
max:
{ _id: ObjectId("60f2ef3bf161e04419477ec3"),
ts: 2021-07-10T00:39:23.000Z,
value: 37.4522108368789 } },
meta: { sensorId: 52396, type: 'windspeed' },
data:
{ value:
{ '0': 18.106480571706808,
...
'999': 3.6329149494110027 },
ts:
{ '0': 2021-07-10T00:00:03.000Z,
...
'999': 2021-07-10T00:39:23.000Z },
_id:
{ '0': ObjectId("60f2ef36f161e0441944f2df"),
...
'999': ObjectId("60f2ef2ff161e044193f73ff")
}
}
}