我正在尝试将此函数从 mapreduce 转换为聚合。
上述函数的结果将是[{pending 1}]
。
当我运行我的匹配组时,我[{pending 0}]
从下面的代码中得到:
mat := bson.M{
"$match": bson.M{"device_id": devId},
}
grp := bson.M{
"$group": bson.M{
"_id": "$status",
"count": bson.M{
"$sum": 1,
},
},
}
pipe := c.Pipe([]bson.M{mat,grp})
pipe.One(&result)
但我认为 mongo shell 中的命令也一样[{pending 1}]。
db.getCollection("auth_sets").aggregate([
{
$match: {
device_id:"5c79601d152ece00012f5831"
}
},
{
$group: {
_id:"$status",
count: {
$sum: 1
}
}
},
]);
我怎样才能得到它,以便我的管道返回[{pending 1}]?
我正在更改它,以便我可以使用 Mongo Atlas 不允许 mapreduce。
墨色风雨
相关分类