I have an array of objects from a database that I want to collapse for succinctness. I've imported underscore.js to help the process, and am unsuccessfully trying to use the 'groupBy' function provided to condense the following list:
[
{ID:2570,name:"jim",latitude:59.4,longitude:-7.29},
{ID:2573,name:"joe",latitude:54.4,longitude:-7.36},
{ID:2573,name:"joe",latitude:54.3,longitude:-7.37},
{ID:2574,name:"bob",latitude:58.4,longitude:-7.31},
{ID:2574,name:"bob",latitude:58.6,longitude:-7.38},
{ID:2574,name:"bob",latitude:58.8,longitude:-7.39},
{ID:2575,name:"mary",latitude:54.1,longitude:-7.30},
]
To the format:
[
{ID:2570, name:"jim", locs : [[59.4,-7.29]]},
{ID:2573, name:"joe", locs : [[54.4,-7.36], [54.3,-7.37]]} //etc...
]