I have the following array of objects that comes from a MySql query:
[
{col1:1, col2:a},
{col1:1, col2:b},
{col1:1, col2:c},
{col1:2, col2:d},
{col1:2, col2:e},
{col1:2, col2:f},
{col1:3, col2:g},
{col1:3, col2:h}
]
I would like to transform into the following object:
[
{col1:1, col2:[a,b,c]},
{col1:2, col2:[d,e,f]},
{col1:3, col2:[e,g,h]}
]
Is there a way to perform this task using map or array filter?