最后每个mongodb $ cond中1和0的用途是什么?

时间:2018-12-11 05:54:25

标签: mongodb mongoose

mngo数据库中最后一个$ cond中的10是什么意思?第4行。

single_registration: { $cond: [
     { $and: [
     { $gte: [ "$registration_created", startDateFirst ] },
     { $lte:[ "$registration_created", endDateFirst ] }
   ] }, 1, 0
] },

1 个答案:

答案 0 :(得分:1)

$cond数组内容的定义是“ if,then,else”。因此,这表示“如果此条件为真,则1,否则为0。”