Lets say have an Array of Objects that looks like this:
let example = [
{
children: [{
data: { id: 2, group: 1001, name: "Audi" },
}],
data: { id: 1, group: 1000, name: "Cars" }
},
{
children: [{
data: { id: 4, group: 1003, name: "Airbus A320" },
}],
data: { id: 3, group: 1002, name: "Planes" }
},
{
children: [{
data: { id: 6, group: 1005, name: "Departed" }
}],
data: { id: 5, group: 1006, name: "movies" }
}
]
In my application the User selects a Tablerow and i get the selected Row Information aka the 'data' object
e.g.
{ id: 2, group: 1001, name: "Audi" }
Now i want to find that selected data object based on the Id
in my Array using lodash or javascript/typescript.
How would i achive that? The children Array causes me problems.
EDIT: The Child of a Child should also be found.
{
children: [{
children: [{
data: {id : 7, group 1001, name: "A8"},
children: [{...}]
}],
data: { id: 2, group: 1001, name: "Audi" },
}],
data: { id: 1, group: 1000, name: "Cars" }
}