我试图在mongoDB上创建一个groupBy,使用cond选择合适的字段,但是,mongo给了我:“字段'$ cond'必须是一个累加器对象”
$group{
"_id" : {"dateId" : "$dateId"},
"estimated" : { "$sum" : "$estimated_records"},
$cond: {
if: {"activeSelfConsumption" : {"$exists" : true}} , (I'm also not sure if this work)
then : {"value" : { "$sum" :"$activeSelfConsumption"}},
else : {"value" : { "$sum" :"$active"}} }
}