-
Notifications
You must be signed in to change notification settings - Fork 0
/
iot.mongodb
35 lines (32 loc) · 1.14 KB
/
iot.mongodb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// MongoDB Playground
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
// Make sure you are connected to enable completions and to be able to run a playground.
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
// Select the database to use.
use('iot');
// Find any bucket document with a measurement where pressure >= 1040
db.schema_demo5.find({'measurements.pressure' : { '$gte' : 1040 }})
// Find any bucket document with a measurement where pressure >= 1040 and filter the sub measurements to only include those readings
// db.schema_demo5.aggregate(
// [
// {
// $match: { "measurements.pressure" : { $gte : 1040 } }
// },
// {
// $project:
// {
// measurement :
// {
// $filter :
// {
// input : "$measurements",
// as : 'item',
// cond : { $gte : ['$$item.pressure', 1040] }
// }
// },
// sensor_id : 1,
// count : 1
// }
// }
// ]
// )