I have array like this:
[
[
{id:1, name:'xxx'}
],
[
{id:2, name:'xxx'},
{id:1, name:'xxx'}
],
[
{id:2, name:'xxx'},
{id:1, name:'xxx'},
{id:3, name:'xxx'}
]
]
I need pick just objects with unique id and merge them into one array. Each object has id property, so I tried this:
_.(data).union().uniqBy(o => o.id).value()
but it gives me wrong result.
My required output should be like this:
[{id:1, name:'xxx'}, {id:2, name:'xxx'}, {id:3, name:'xxx'}]
Can you help me with that? Thanks.
_.uniqBy(_.flattenDeep(data), "id")do what you're wanting?