Azure DocumentDB ARRAY_CONTAINS on subdocuments

It seems that the function ARRAY_CONTAINSon the attached documents never matches any document.

For example, trying the simplest simple query with Azure DocumentDB Query Playground will not return any result, even if some subdocuments must match this query.

SELECT *
FROM food
WHERE ARRAY_CONTAINS(food.tags.name, "blueberries")

In a past question in Qaru, it was also pointed out that this type of subqueries is valid.

thank

+4
source share
1 answer

The first argument to ARRAY_CONTAINS should be an array. For example, in this case food.tags is valid as an argument, but food.tags.name is not.

DocumentDB , :

SELECT food
FROM food
JOIN tag IN food.tags
WHERE tag.name = "blueberries"

SELECT food
FROM food
WHERE ARRAY_CONTAINS(food.tags, { name: "blueberries" })
+5

Source: https://habr.com/ru/post/1661227/


All Articles