Source data:
data: [
{
parkId: 1,
scheduleId: 1,
hasStock: false
},
{
parkId: 1,
scheduleId: 2,
hasStock: false
},
{
parkId: 1,
scheduleId: 3,
hasStock: false
},
{
parkId: 2,
scheduleId: 1,
hasStock: false
},
{
parkId: 2,
scheduleId: 2,
hasStock: false
},
{
parkId: 2,
scheduleId: 3,
hasStock: false
}
]
expect items with the same parkId to be merged into the following format:
[
{
parkId: 1,
date: [
{
scheduleId: 1,
hasStock: false
},
{
scheduleId: 2,
hasStock: false
},
{
scheduleId: 3,
hasStock: false
}
]
},
{
parkId: 2,
date: [
{
scheduleId: 1,
hasStock: false
},
{
scheduleId: 2,
hasStock: false
},
{
scheduleId: 3,
hasStock: false
}
]
}
]
do you bosses have any more elegant ways