0
Hello,
I have the following data structure:
[
{id:1,idforeign:2,nome:'etc'},
{id:2,idforeign:2,nome:'etc'},
{id:3,idforeign:3,nome:'outro'},
{id:4,idforeign:3,nome:'outro'}
]
I’d like to turn to something like this:
[
{nome:'etc', dados:[
{id:1,idforeign:2},
{id:2,idforeign:2}
]
},
{nome:'outro', dados:[
{id:3,idforeign:3},
{id:4,idforeign:3}
]
}
]
I’ve tried something like this: Group and add array in Javascript
But it didn’t work very well the adaptations I made, someone knows an easy way to do it?