Get only selected indexes from array of object

I want to use a N1QL select query and get only the keys I need from the objects in data array.

SELECT data[].alpha2Code, data[].alpha3Code FROM meta USE KEYS ['countrylist']

Expected result:

{
"data": [
        {
            "alpha2Code": "AF",
            "alpha3Code": "AFG"
        },
        {
            "alpha2Code": "AX",
            "alpha3Code": "ALA"
        },
        {
            "alpha2Code": "AL",
            "alpha3Code": "ALB"
        }
    ]
}

Source data:

{
    "id": "countrylist",
    "data": [
        {
        "alpha2Code": "AF",
        "alpha3Code": "AFG",
        "altSpellings": [
            "AF",
            "Afġānistān"
        ],
        "area": 652230
        },
        {
        "alpha2Code": "AX",
        "alpha3Code": "ALA",
        "altSpellings": [
            "AX",
            "Aaland",
            "Aland",
            "Ahvenanmaa"
        ],
        "area": 1580
        },
        {
        "alpha2Code": "AL",
        "alpha3Code": "ALB",
        "altSpellings": [
            "AL",
            "Shqipëri",
            "Shqipëria",
            "Shqipnia"
        ],
        "area": 28748
        }
    ]
}
SELECT ARRAY  {v.alpha2Code , v.alpha3Code } FOR v IN data END AS data
FROM meta USE KEYS ['countrylist']
1 Like

Works perfectly! Thank you!