我的收藏会看起来像,
{
"_id" : ObjectId("55c8bd1d85b83e06dc54c0eb"),
"name" : "xxx",
"salary" : 10000,
"type" : "type1"
}
{
"_id" : ObjectId("55c8bd1d85b83e06dc54c0eb"),
"name" : "aaa",
"salary" : 10000,
"type" : "type2"
}
{
"_id" : ObjectId("55c8bd1d85b83e06dc54c0eb"),
"name" : "ccc",
"salary" : 10000,
"type" : "type2"
}
Run Code Online (Sandbox Code Playgroud)
我的查询参数将会出现,
{salary = 10000,type = type2}
所以基于查询我需要获取上述查询参数的计数
结果应该是这样的,
{category:'type1',count:500} {category:'type2',count:200} {category:'name',count:100}
现在我通过点击三个不同的查询并构造结果(或)服务器端迭代来获得计数,我可以得到结果.
任何人都可以建议或提供我获得上述结果的好方法