first和nexrt是前文查出来的值,现在要判断这adate是否大于fisrt(临时变量f_time),小于next(临时变量n_time)
{
"$project": {
"diag": 1,
"first": 1,
"next": {"$ifNull":["$next",new ISODate()]} ,
"result": {
"$let": {
"vars": {
"f_time": "$first",
"n_time": "$next"
},
"in": {
"$cond": [
{
"$and": [
{
"$gte": [
"$adate",
"$$f_time"
]
},
{
"$lte": [
"$adate",
"$$n_time"
]
}
]
},
1,
0
]
}
}
}
}
},