title: Get count of distinct values in a column grouped by date mongodb
body: <p>I am trying to run a mongodb query that for each day requested it will return the count of unique values in a different column. For instance for the month of june the query will return the date as well as the count of distinct values were in the b column on the date. Any one know how to do this I have tried a couple different things with no luck</p>
  
  <p>Below are a couple sample documents, as well as what the output should be </p>
  
  <pre><code>{
    "_id" : ObjectId("578fa05a7391bb0d34bd3c28"),
    "IP" : "123.123.123.123",
    "datetime" : ISODate("2016-07-20T10:04:56-05:00")
  },
  {
    "_id" : ObjectId("578fa05a7391bb0d34bd3c28"),
    "IP" : "110.123.1.2",
    "datetime" : ISODate("2016-07-20T10:04:56-05:00"),
  }
  </code></pre>
  
  <p>Output should be </p>
  
  <pre><code>{
  "date":"2016-07-20",
  count:2 -- this is distinct number of IPs for the date above
  }
  </code></pre>