DocumentDB SQL with ARRAY_CONTAINS

前端 未结 4 1734
眼角桃花
眼角桃花 2020-12-11 15:45

I\'m playing around on https://www.documentdb.com/sql/demo, which allows me to query against sample documents that look like:

{
  \"id\": \"19015\",
  \"desc         


        
4条回答
  •  星月不相逢
    2020-12-11 16:23

    Not sure if this functionality was available when you were looking at the API originally but the ARRAY_CONTAINS now supports an optional Boolean value at the end to provide partial match support.

    SELECT root
    FROM root
    WHERE ARRAY_CONTAINS(root.servings, { "description": "bar" }, true)
    

    Here is sample using the documentdb demo site that queries an array that contains multiple fields for each object stored.

    SELECT  *
    FROM    food as f
    WHERE   ARRAY_CONTAINS(f.servings, {"description":"bar"}, true)
    

提交回复
热议问题