0
{
    "_id": "445454",
    "students": ["7894556", "5454454"]
}

This is my actual data. After first lookup I got a result like:

{
    "_id": "445454",
    "students": [{
        "name": "Jose",
        "parent": "45566622"
    },{
        "name": "Mathew",
        "parent": "7889665"
    }]
}

but actual answer I required is something like this

{
    "_id": "445454",
    "students": [{
        "name": "Jose",
        "parent": {
            "_id": "45566622",
            "name": "Cristy"
        }
    }, {
        "name": "Mathew",
        "parent": {
            "_id": "7889665",
            "name": "Abraham"
        }
    }]
}

somebody please help me. I not expert in mongodb.

  • 1
    Use lookup followed by unwind, then again use lookup followed by group. If you have posted the complete data I could have answered you. Maybe this can help you: https://stackoverflow.com/questions/36019713/mongodb-nested-lookup-with-3-levels/52574565 – MilanRegmi Mar 19 '20 at 10:59
  • Where should `"name": "Cristy"` be coming from? – Joe Mar 19 '20 at 21:46

0 Answers0