Query cosmos db siblings with no childs

Author: Thomas Segato

Originally Sourced from: https://stackoverflow.com/questions/52753783/query-cosmos-db-siblings-with-no-childs

Is it possible to query cosmos db without returning child? I want following result:

[{"groupId":1,"name":"group1"},{"groupId":2,"name":"group2"}]

From following:

{
    "groups":
    [
        {
            "groupId":1,
            "name":"group1",
            "subgroups":
            [
                {
                    "subGroupId":1,
                    "name":"subgroup1"
                },
                {
                    "subGroupId":2,
                    "name":"subgroup2"
                }
            ]
        },
        {
            "groupId":2,
            "name":"group2",
            "subgroups":
            [
                {
                    "subGroupId":1,
                    "name":"subgroup1"
                },
                {
                    "subGroupId":2,
                    "name":"subgroup2"
                }
            ]
        }
    ]
}

I would prefer it without trigger so pure select.