嵌套文档上的Azure DocumentDB ARRAY_CONTAINS [英] Azure DocumentDB ARRAY_CONTAINS on nested documents
问题描述
嵌套文档上的ARRAY_CONTAINS
函数似乎从不匹配任何文档.
It seems like the ARRAY_CONTAINS
function on nested documents never matches any document.
For example, trying the following simple query with the Azure DocumentDB Query Playground would return no result, even if some nested documents should match this query.
SELECT *
FROM food
WHERE ARRAY_CONTAINS(food.tags.name, "blueberries")
过去关于Stack Overflow的问题也推断出这种嵌套查询是有效的.
This past question on Stack Overflow also infered that this kind of nested query is valid.
谢谢
推荐答案
ARRAY_CONTAINS的第一个参数必须是数组.例如,在这种情况下,food.tags作为参数有效,但food.tags.name无效.
The first argument to ARRAY_CONTAINS must be an array. For example, in this case food.tags is valid as an argument, but food.tags.name is not.
以下两个DocumentDB查询都是有效的,并且可能正是您要寻找的:
Both the following DocumentDB queries are valid and might be what you're looking for:
SELECT food
FROM food
JOIN tag IN food.tags
WHERE tag.name = "blueberries"
或
SELECT food
FROM food
WHERE ARRAY_CONTAINS(food.tags, { name: "blueberries" })
这篇关于嵌套文档上的Azure DocumentDB ARRAY_CONTAINS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!