title: group by dates in mongodb
body: <p>I am working on a project in which I am tracking number of clicks on a topic.</p>
  
  <p>I am using mongodb and I have to group number of click by date( i want to group data for 15 days).</p>
  
  <p>I am having data store in following format in mongodb</p>
  
  <pre><code>{ 
     "_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"
  }
  </code></pre>
  
  <p>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</p>
  
  <p>I am looking for result in following format</p>
  
  <pre><code>[
    {
      "date" : "date in log",
      "click" : 9 
    },  
    {
      "date" : "date in log",
      "click" : 19
    },  
  ]
  </code></pre>
  
  <p>I have written code but it will work only if date are in string (code is here <a href="http://pastebin.com/2wm1n1ix" rel="noreferrer">http://pastebin.com/2wm1n1ix</a>)
  ...please guide me how do I group it</p>