Loop on couchbase wiew?

Hello,

I’m new on couchbase.
On my database I have coordinates data (latitude and longitude) for different hours.
On a view I’m trying to regroup latitude and longitude of 2 hours to then calculate the distance between my 2 points, and do the same with the next point etc…

For example I have :

[ 2017, 3, 20, 18, 58, 1]
[43.61852333333333,
  3.9157633333333335] 

and

[ 2017, 3, 20, 19, 58, 1]
[43.81452333333333,
  3.1157633333333335] 

and I want to obtain this :

[ 2017, 3, 20, 18, 58, 1]
[43.61852333333333,
  3.9157633333333335] 
[43.81452333333333,
  3.1157633333333335] 

I try to do a loop but it seems to be not working.

Can everyone have a solution to do that ?