Iterate through Date for the last 7 days
<p>I need to build a array of objects to show data on a graph which shows the data for the last 7 days. At times certain of the 7 days record will be absent in the database and hence i need to show the record and mark the value as 0 to have 7 objects in the array.</p>

<p>Right now i have</p>

<pre><code>[
  {
    "date": "2016-05-14",
    "amount": 6000
  },
  {
    "date": "2016-05-12",
    "amount": 12000
  }
]
</code></pre>

<p>What i want is </p>

<pre><code>[
    {
        "date": "2016-05-14",
        "amount": 6000
    },
    {
        "date": "2016-05-13",
        "amount": 0
    },
    {
        "date": "2016-05-12",
        "amount": 12000
    },
    {
        "date": "2016-05-11",
        "amount": 0
    },
    {
        "date": "2016-05-10",
        "amount": 0
    },
    {
        "date": "2016-05-09",
        "amount": 0
    },
    {
        "date": "2016-05-09",
        "amount": 0
    }
]
</code></pre>