I want to aggregate and display only the last object in a nested array This is my DB:
[{
"firstName": "Shaun",
"salary": [
{
"id":1,
"rate": 250,
},
{
"id":2,
"rate": 290,
}
]
},{
"firstName": "Julian",
"salary": [
{
"id":1,
"rate": 750,
},
{
"id":2,
"rate": 760,
},
{
"id":3,
"rate": 790,
},
]
}
}]
My desired result is :
{"firstName": "Shaun", "rate":290},{"firstName": "Julian", "rate":790}