I am trying to convert this function here from mapreduce to aggregation.
The result from above function will be [{pending 1}]
.
When I run my match group I get [{pending 0}]
from the following code below:
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)
But the same I think command in mongo shell gives [{pending 1}]
.
db.getCollection("auth_sets").aggregate([
{
$match: {
device_id:"5c79601d152ece00012f5831"
}
},
{
$group: {
_id:"$status",
count: {
$sum: 1
}
}
},
]);
How can I get it so my pipe will return [{pending 1}]
?
I am changing it so I can use Mongo Atlas with does not allow mapreduce.