查询没有孩子的cosmos db兄弟姐妹

时间:2018-10-11 06:39:39

标签: azure-cosmosdb

是否可以在不返回子对象的情况下查询cosmos db?我想要以下结果:

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

来自以下内容:

{
    "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"
                }
            ]
        }
    ]
}

我希望它不带触发器就这么纯净地选择。

1 个答案:

答案 0 :(得分:1)

只需使用join关键字:

inds <- ncol(df1)/2

df1[paste0("diff", names(df1[(inds + 1):ncol(df1)]), names(df1[1:inds]))] <- 
           df1[(inds + 1):ncol(df1)] - df1[1:inds]

输出:

enter image description here

希望它对您有帮助。