considering the sample document below
{
"user_id": "user 1",
"log":[
{
"index" : 1,
"position" : 50
},
{
"index" : 2,
"position" : 70
},
{
"index" : 3,
"position" : 60
}
]
},
{
"user_id": "user 2",
"log":[
{
"index" : 1,
"position" : 150
},
{
"index" : 2,
"position" : 570
},
{
"index" : 3,
"position" : 60
}
]
},
how do I fetch the user_id with the highest recorded position and its corresponding index in the mongo shell? For this example, the expected outcome should be:
- user_id="user 2"
- position = 570
- index = 2
Appreciate your help!