I have data in MongoDB in the form of :
{
"_id" : 154,
"record_id" : "001280000033x54AAA",
"jsonData" : "",
"user_id" : 1,
"userName" : "abc@xyz.com",
"backup_no" : 1
}
{
"_id" : 155,
"record_id" : "001280000033x54AAA",
"jsonData" : "",
"user_id" : 1,
"userName" : "abc@xyz.com",
"backup_no" : 2
}
...
I want to retrieve data based on 'user_id','userName', but if a record with same record_id exists in lower 'backup_no' then i need to choose record with highest backup_no.
I have tried to aggregate record_id's and then query but i am unable to find a solution.
Thanks