title: Group and count over a start and end range
body: <p>If I have data in the following format:</p>
  
  <pre><code>[
    {
      _id: 1,
      startDate: ISODate("2017-01-1T00:00:00.000Z"),
      endDate: ISODate("2017-02-25T00:00:00.000Z"),
      type: 'CAR'
    },
    {
      _id: 2,
      startDate: ISODate("2017-02-17T00:00:00.000Z"),
      endDate: ISODate("2017-03-22T00:00:00.000Z"),
      type: 'HGV'
    }
  ]
  </code></pre>
  
  <p>Is it possible to retrieve data grouped by 'type', but also with a count of the type for each of month in a given date range e.g. between 2017/1/1 to 2017/4/1 would return: </p>
  
  <pre><code>[
    {
     _id: 'CAR', 
     monthCounts: [
       /*January*/
       {
         from: ISODate("2017-01-1T00:00:00.000Z"), 
         to: ISODate("2017-01-31T23:59:59.999Z"), 
         count: 1
       },
       /*February*/
       {
         from: ISODate("2017-02-1T00:00:00.000Z"), 
         to: ISODate("2017-02-28T23:59:59.999Z"), 
         count: 1
       },
       /*March*/
       {
         from: ISODate("2017-03-1T00:00:00.000Z"), 
         to: ISODate("2017-03-31T23:59:59.999Z"), 
         count: 0
       },
     ]
    },
    {
     _id: 'HGV', 
     monthCounts: [
       {
         from: ISODate("2017-01-1T00:00:00.000Z"), 
         to: ISODate("2017-01-31T23:59:59.999Z"), 
         count: 0
       },
       {
         from: ISODate("2017-02-1T00:00:00.000Z"), 
         to: ISODate("2017-02-28T23:59:59.999Z"), 
         count: 1
       },
       {
         from: ISODate("2017-03-1T00:00:00.000Z"), 
         to: ISODate("2017-03-31T23:59:59.999Z"), 
         count: 1
       },
     ]
    }
  ]
  </code></pre>
  
  <p>The returned format is not really important, but what I am trying to achieve is in a single query to retrieve a number of counts for the same grouping (one per month).  The input could be simply a start and end date to report from or more likely it could be an array of the date ranges to group by.</p>