我的收藏就像
{queid:'1',date:'07023/2013',topic: 'topic1'}
{queid:'2',date:'07022/2013',topic: 'topic2'}
{queid:'3',date:'07022/2013',topic: 'topic1'}
{queid:'4',date:'07023/2013',topic: 'topic1'}
我希望我的输出像
{topic1:
[ {date:'07/23/2013',count:2},
{date:'07/22/2013',count:1}
]
}
这可以做到吗mongodb ..
我试着这样做
que.aggregate([{$match:c},{$group:{_id:'$topic',count:{$push:'$date'}}}])
输出为
{
"_id" : "topic",
"count" : [
"2013-06-04",
"2013-06-06",
"2013-06-17",
"2013-06-20"
] }
我无法理解如何在数组中分组并填充计数。