I have an object array as follows. I need the unique objects based the _id field of the application object inside the group.
const myObjArray:any = [
{
"group": {
"name": "SAM-admin",
"active": true,
"application": {
"_id": "g4fac238hma10kjo3mv473vbs",
"name": "Prism",
"owners": "",
"url": "",
"description": "",
"active": "",
"created_by": "",
"updated_by": ""
},
"created_by": "",
"updated_by": "",
},
"user": "g4fac238hma10kjo3mv473vbs",
"role": "g4fac238hma10kjo3mv473vbs",
"isAdmin": true,
"active": true,
"created_by": "[email protected]",
"updated_by": "",
},
{
"group": {
"name": "SAM-super-admin",
"active": true,
"application": {
"_id": "g4fac238hma10kjo3mv473asc",
"name": "Utopia",
"owners": "",
"url": "",
"description": "",
"active": "",
"created_by": "",
"updated_by": ""
},
"created_by": "",
"updated_by": "",
},
"user": "g4fac238hma10kjo3mv473asc",
"role": "g4fac238hma10kjo3mv473asc",
"isAdmin": true,
"active": true,
"created_by": "[email protected]",
"updated_by": "",
}
,
{
"group": {
"name": "SAM-guest",
"active": true,
"application": {
"_id": "g4fac238hma10kjo3mv473asc",
"name": "Utopia",
"owners": "",
"url": "",
"description": "",
"active": "",
"created_by": "",
"updated_by": ""
},
"created_by": "",
"updated_by": "",
},
"user": "g4fac238hma10kjo3mv473asc",
"role": "g4fac238hma10kjo3mv473asc",
"isAdmin": true,
"active": true,
"created_by": "[email protected]",
"updated_by": "",
}
];
Here in myObjArray the second and third elements are having group object with same application _id
Hence i need to remove the third object.
How to do this at the easiest way in typescript.