title: skipped count 0 in aggregate function
body: <p>I'm stuck on this for couple of days. I'm trying to get the <code>count: 0</code> where there is no documents in the given time period. This is the aggregate function I'm using at the moment:</p>
  
  <pre><code>var getCount = function(timeBlock, start, end, cb) {
  
      Document.aggregate(
      {
          $match: {
              time: {
                  $gte: new Date(start),
                  $lt: new Date(end)
              }
          }
      },
  
      {
          $project: {
              time: 1,
              delta: { $subtract: [
                  new Date(end),
                  '$time'
              ]}
          }
      },
  
      {
          $project: {
              time: 1,
              delta: { $subtract: [
                  "$delta",
                  { $mod: [
                      "$delta",
                      timeBlock
                  ]}
              ]}
          }
      },
  
      {
          $group: {
              _id: { $subtract: [
                  end,
                  "$delta"
              ]},
              count: { $sum: 1 }
          }
      },
  
      {
          $project: {
              time: "$_id",
              count: 1,
              _id: 0
          }
      },
  
      {
          $sort: {
              time: 1
          }
  
      }, function(err, results) {
          if (err) {
              cb(err)
          } else {
              cb(null, results)
          }
      })
  }
  </code></pre>
  
  <p>I tried using <code>$cond</code>, but with no luck</p>