How to add missing dates to data

The solution that i gave i dont know if its good one, i still believe that its better to be done in javascript and not in the server like steevej said, but if you want to know what i did.

  • i created a collection with dates, with difference 1 day (1 document = 1 day) (step 1,2)
    you can make a collection with 1 year or more its nothing to have 365 documents collection
  • i joined($lookup) that collection with the orders collections, and put all the orders that made that day to an array (step 3)

I used the JSON syntax not the Javascript object syntax its the same, but JSON is the common way to write queries that can be used across many languages.

If you are new in MongoDB that queries might look complicated and can make you more confused.If you can try the javascript way to add the dates after you get the data from the server.

I hope you find a way to do it.