I am working on a leaderboard and each user has many records on the leaderboards table. Here's the object it returns
[
{
"user_id": 3,
"user_name": "Langosh Troy",
"points": 78
},
{
"user_id": 3,
"user_name": "Langosh Troy",
"points": 76
},
{
"user_id": 1,
"user_name": "Crooks Elsa",
"points": 12
}
]
But I want it to appear such that the object with user_id = 3 would become one object so my final return value should look this way
[
{
"user_id": 3,
"user_name": "Langosh Troy",
"points": 154
},
{
"user_id": 1,
"user_name": "Crooks Elsa",
"points": 12
}
]