我正在从事一个项目,其中我跟踪一个主题的点击次数。
我正在使用 mongodb,我必须按日期分组点击次数(我想分组数据为15天)。
我有以下格式的数据存储在 mongodb
{
"_id" : ObjectId("4d663451d1e7242c4b68e000"),
"date" : "Mon Dec 27 2010 18:51:22 GMT+0000 (UTC)",
"topic" : "abc",
"time" : "18:51:22"
}
{
"_id" : ObjectId("4d6634514cb5cb2c4b69e000"),
"date" : "Mon Dec 27 2010 18:51:23 GMT+0000 (UTC)",
"topic" : "bce",
"time" : "18:51:23"
}
i want to group number of clicks on topic:abc by days(for 15 days)..i know how to group that but how can I group by date which are stored in my database
我在寻找以下格式的结果
[
{
"date" : "date in log",
"click" : 9
},
{
"date" : "date in log",
"click" : 19
},
]
我已经写了代码,但它将工作,只有当日期是在字符串(代码是这里 http://pastebin.com/2wm1n1ix) 请指导我如何分组