I have 1 employee table, employee error after I query and add to array js like this:
[
{ id: 01,
name: a,
error: "late",
counterorr: 3
},
{ id:01,
name: a,
error: "forgot homework",
counterorr:2
},
{ id: 02,
name: b,
error: "late",
counterorr:2
}
]
I'm not very good with json and handling them so I don't understand how to best store it What I want to display on the screen:
{id:01, name: a,error:[{nameErorr: late,counterorr:3}, {nameErorr:forgot homework,counterorr:3
}], id: 02, name: b, error:[{nameErorr:"late",counterorr:2}]}
I can't find a better way to store it, if so please help me, thanks
I will describe it more simply than this
user=[{
id: 01,
have: orange
number: 1
},{
id: 01,
have: banana
number: 2
},{
id: 02,
have: orange
number: 1
}]
i want to convert that array to like this
user=[{
id: 01,
have: [{name: orange, number: 1}, {name: banana, number: 2}]
},{
id: 02,
have: [{name: orange, number: 1}]
}]
is this possible using lodash _groupby?