-
Notifications
You must be signed in to change notification settings - Fork 5
/
mongoaggregate.txt
44 lines (26 loc) · 1.14 KB
/
mongoaggregate.txt
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
{$expr:{$gt:[{'$subtract':['$lastUpdate','$eventStartDate']},1000*60*60*24]}}
// work
db.events.find( {$expr: {$lte:[{"$subtract":["$date","$eventStartDate"]}, 60000000] } } )
// เวลาผ่านไปแล้วแต่ยังไม่เคยปลัก flag ก็ต้องดึงขึ้นมาแปะป้าย
// เวลาผ่านไปแล้ว
db.events.find( {$expr: { $or: [ {$lte:[{"$subtract":["$date","$eventStartDate"]}, 60000000] } , {$eq: ["$isEventStart", false] } ]} } )
db.events.find( $expr: { $and: [ ] } )
db.events.aggregate( [ { $project: { time: { $subtract: [ new Date() , "$eventStartDate" ] } } }, {
$addFields: {
totalHomework: { $subtract: [ new Date() , "$eventStartDate" ] } ,
totalQuiz: { $subtract: [ new Date() , "$eventStartDate" ] }
}
} ] );
db.events.aggregate( [ { $project: { totalHourSpent:{$divide : [{$subtract: ["$date","$date"]}, 3600000] } } } ] );
db.events.aggregate([
{
$addFields: {
dateDifference: {
$subtract: [
"$date",
"$eventStartDate"
]
}
}
},
])