【问题标题】:Select value from array of objects Cosmos DB从对象数组 Cosmos DB 中选择值
【发布时间】:2020-05-20 09:32:49
【问题描述】:

我有以下 json

{
"car-id": "54-38ncv",
"cars": [
{
"name": "Ferrari",
"horse-powers": 400
},
{
"name": "BMW",
"horse-powers": 200
},
{
"name": "Audi",
"horse-powers": 145
}]
}

id 是我自定义设置的。想象一下,我的 azure cosmos db 集合中有数百个其他文档。我想创建查询来选择第一个文档,该文档在名为“Ferrari”的汽车中包含汽车。我知道他们可能是重复的,但想要第一个。有没有这方面的采石场。

【问题讨论】:

    标签: json azure azure-cosmosdb


    【解决方案1】:

    你可以这样做,

    SELECT TOP 1 FROM c JOIN cc IN c.cars WHERE cc.name IN ("Ferrari")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 2022-01-02
      • 1970-01-01
      • 1970-01-01
      • 2019-11-18
      相关资源
      最近更新 更多