Azure DocumentDB ARRAY_CONTAINS on nested documents

烂漫一生 提交于 2019-12-09 18:34:13

问题


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")

This past question on Stack Overflow also infered that this kind of nested query is valid.

Thank you


回答1:


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.

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"

Or

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


来源:https://stackoverflow.com/questions/40683533/azure-documentdb-array-contains-on-nested-documents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!