I have this object
users : [
{
_id: "5",
name: "tomek"
},
{
_id: "6",
name: "janek"
},
{
_id: "7",
name: "Jakub"
},
{
_id: "8",
name: "Piotr"
}
],
groups : [
{
users: ["5", "6"],
_id: "22",
name: "group 1"
},
{
users: ["7"],
_id: "33",
name: "group 2"
}
]
}
and I would like to modify it, that he looked like this
group:[{name:'group 1',user:[{objects with users belonging to the first group },{...},{...}]}, {name:'group 2',users:[{obj with users belonging to the first group},{...}]},{name:'no group'
,users:[{
objects with users not belonging to any group}]}
}
based on the above object, I would like to do one, Users without group should be thrown into group:'NO GROUP",
name:'grupa one', but this isn't in your input code. Is this a typo, or do you actually want that?