forked from damews/BlueApiFunctions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquery.js
49 lines (47 loc) · 1.48 KB
/
query.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb+srv://bluedb:[email protected]/IBLUEIT?retryWrites=true&w=majority";
MongoClient.connect(url, function (err, db) {
if (err) throw err;
var dbo = db.db("IBLUEIT");
db.plataformoverview.aggregate(
[
{
$project:
{
created_at:
{
$dateToString:
{
format: "%Y-%m-%d", date: "$created_at"
}
},
pacientId: 1,
playStart: 1,
flowDataDevicesId: 1
}
},
{
$lookup:
{
from: 'flowdatadevices',
let: { flowDataDeviceId: "$flowDataDevicesId" },
localField: '',
pipeline: [
{
$match:
{
$expr: { $eq: ['$_id', '$$flowDataDeviceId'] }
}
},
{ $project: { flowDataDevices: 1 } }
],
as: 'flowData'
}
}
]
).toArray(function (err, result) {
if (err) throw err;
console.log(result);
db.close();
});
});