title: MongoDB fill-in data that is not included in the query result
body: <p>Let's say I have a collection that contains this data:</p>
  
  <pre><code>{"date" : ISODate("2018-01-01T00:00:00Z"), "count" : 3 }
  {"date" : ISODate("2018-01-04T00:00:00Z"), "count" : 5 }
  </code></pre>
  
  <p>What mongodb functions should I use so that I can generate a query that will result to this:</p>
  
  <pre><code>{"date" : ISODate("2018-01-01T00:00:00Z"), "count" : 3 }
  {"date" : ISODate("2018-01-02T00:00:00Z"), "count" : 0 }
  {"date" : ISODate("2018-01-03T00:00:00Z"), "count" : 0 }
  {"date" : ISODate("2018-01-04T00:00:00Z"), "count" : 5 }
  {"date" : ISODate("2018-01-05T00:00:00Z"), "count" : 0 }
  </code></pre>
  
  <p>Basically, I want to iterate a date range and if that given date is not in the collection, I will just output a 'count':0 for it.</p>
  
  <p>I can probably do this by just retrieving the documents and have a javascript code that will fill in the data that's not in the results but I would just like to know if it's possible by only using mongodb query.</p>
  
  <p>Thanks!</p>