I have a users collection with the following structure:
[
{
name: "xxx",
labels: [
{
category: "Language",
values: ["English", "Spanish"],
},
{
category: "Hobby",
values: ["Read", "Cook", "Read"],
},
]
},
{
name: "yyy",
labels: [
{
category: "Language",
values: ["English", "English"],
},
{
category: "Hobby",
values: ["Read", "Play", "Play"],
},
]
},
]
I want to delete all duplicates from values array, so the result would be:
[
{
name: "xxx",
labels: [
{
category: "Language",
values: ["English", "Spanish"],
},
{
category: "Hobby",
values: ["Read", "Cook"],
},
]
},
{
name: "yyy",
labels: [
{
category: "Language",
values: ["English"],
},
{
category: "Hobby",
values: ["Read", "Play"],
},
]
},
]
I tried to use setUnion and setIntersection, but I didn't know what is the right why to use them with a nested array.