我在Mongodb中运行聚合查询
db.Data_Urls.aggregate([{$group : {_id : "$Urls", Done:{$sum:1}}}])
所以结果就像
{
"_id" : "hassan",
"Done" : NumberInt(1)
},
{
"_id" : "ahmed",
"Done" : NumberInt(3)
},
{
"_id" : "naveed",
"Done" : NumberInt(1)
},
{
"_id" : "ali",
"Done" : NumberInt(1)
},
{
"_id" : "haroon",
"Done" : NumberInt(2)
}
我想在同一查询中过滤Done
值,只获取值为1的Done
值?
答案 0 :(得分:0)
db.Data_Urls.aggregate([
{$group : {_id : "$Urls", Done:{$sum:1}}},
{$match : { Done: 1 }}
])