小编jas*_*jas的帖子

从CosmosDB中文档嵌套数组中的对象中选择值

想象我们有一个这样的集合(示例取自 https://www.documentdb.com/sql/demo

{
    "_id" : "19015",
    "description" : "Snacks, granola bars, hard, plain",
    "servings" : [ 
        {
            "amount" : 1,
            "description" : "bar",
            "weightInGrams" : 21
        }, 
        {
            "amount" : 1,
            "description" : "bar (1 oz)",
            "weightInGrams" : 28
        }, 
        {
            "amount" : 1,
            "description" : "bar",
            "weightInGrams" : 25
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我如何在SQL api中查询CosmosDB以获取这样的结果?

{
    "_id" : "19015",
    "servings" : [ 
        {
            "description" : "bar"
        }, 
        {
            "description" : "bar (1 oz)"
        }, 
        {
            "description" : "bar"
        } …
Run Code Online (Sandbox Code Playgroud)

azure-cosmosdb azure-cosmosdb-sqlapi

3
推荐指数
2
解决办法
1764
查看次数