Query CosmosDb - where array contains item(s) from array

前端 未结 3 773
执笔经年
执笔经年 2021-01-01 20:09

I don\'t know if there is a word for this, guess there is, but right now I couldn\'t explain it better than \"where array contains item(s) from array\".

It might sou

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 20:56

    You can do something like this: For each item in ZipCodes, you get a zip and compare with the array of codes you are checking. This, IMHO, is much better than using UDF.

    {
      query: '
             SELECT DISTINCT value r
             FROM root r
             JOIN zip IN r.zipCodes
             WHERE ARRAY_CONTAINS(@zipIds, zip, true)
             ',
      parameters: [{name: "@zipIds", value: zipIds}]
    }
    

    The last param of ARRAY_CONTAINS tells the function to accept partial matches.

提交回复
热议问题