【发布时间】:2016-05-30 04:07:42
【问题描述】:
我试图在聚合$group 期间使用$cond 有条件地将$push 多个整数放到数字数组中,但没有任何成功。这是我的代码:
Item.aggregate(
[
{
$group: {
_id: "$_id",
numbers: {
$push: {
$cond: {
if: { $gt: [ "$price.percent", 70 ] },
then: { $each: [10,25,50,70] },
else: null,
}
}
}
}
},
]
)
...
Mongo DB 是不是现在没有为此设置,还是我看错了?
【问题讨论】:
标签: node.js mongodb express mongoose mongodb-query