嵌套文档上的Azure DocumentDB ARRAY_CONTAINS [英] Azure DocumentDB ARRAY_CONTAINS on nested documents

查看:65
本文介绍了嵌套文档上的Azure DocumentDB ARRAY_CONTAINS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嵌套文档上的ARRAY_CONTAINS函数似乎从不匹配任何文档.

It seems like the ARRAY_CONTAINS function on nested documents never matches any document.

例如,尝试使用Azure DocumentDB

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆