'mongodb aggregations code for different language data in Nestjs

my database

{
    "_id": {
        "$oid": "ddfsfs"
    },
    "id": 3,
    "parent_id": 6,
    "translation":
       [
        {
        "language": "en",
        "desc": "prod detail",
        "name": "example1"
        },
        {
        "language": "tr",
        "desc": "detaylar",
        "name": "ornek1"
        }
       ]
}

I want to make this : For example, only the English field is selected. Is it okay if it has only the name and description in the English field in its final form? and How?

{
    "_id": {
        "$oid": "ddfsfs"
    },
     "id": 3,
     "parent_id": 6,
     "desc": "prod detail",
     "name": "example1"   
}

or the database can be like this. again only the english field will remain

{
    "_id": {
        "$oid": "62189ffd81f6b6bb05d8d409"
    },
    "id": 7,
    "parent_id": 8,
    "en": {
        "desc": "hii",
        "name": "serial ethernet"
    },
    "tr": {
        "desc": "merhaba",
        "name": "seri ethernet"
    }
}

please share me mongodb aggregations code for use in nestjs. thank you!:)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source