momgo查询,使用临时变量判断

来源:互联网 发布:unity3d guitexture 编辑:程序博客网 时间:2024/06/06 03:13

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            ]          }        }      }    }  },
原创粉丝点击