I need to return a value for every date between a start and end date.
For each row
: if the date exists in row.date
, then I need to return row.myValue
else I need to return null.
Example:
dateRange = {start: '2018-01-01', end: '2018-01-03'}
aqlCollection = [
{date: '2018-01-01', myVal: 1},
{date: '2018-01-02', myVal: 2},
{date: '2017-05-18', myVal: 3}
]
This should return:
[
{'2018-01-01': 1},
{'2018-01-02': 2},
{'2018-01-03': null}
]
This can be accomplished simply if there was a WHILE
loop in arangodb. Or if I could for loop using an incrementer instead of doing FOR date IN dates
then I could just say FOR date=startRange; date<endRange; date+=24hrs
.
Any ideas on how this can be achieved within an Arango query? If it is not possible I will do an O(n) loop over after a simple group by date query and add in all the dates that do not exist.