如何查询名称中带有空格的属性

时间:2021-04-09 07:38:07

标签: arangodb aql

可能是一个愚蠢的问题,但如果在集合中我有包含用空格定义的属性的文档,例如:

{
 "attribute with spaces" : "blabla",
 ...
}

如何查询才能找到它?我试过了

for document in documents
    filter document."attribute with spaces" == "blabla"

但我当然会遇到语法错误。

1 个答案:

答案 0 :(得分:3)

作为保留关键字或包含空格或属性名称中不允许的其他字符的属性名称必须用反引号引用:

FOR document IN documents
    FILTER document.`attribute with spaces` == "blabla"

或者,您可以像这样使用属性访问:

FOR document IN documents
    FILTER document["attribute with spaces"] == "blabla"

这也在文档中进行了解释:https://www.arangodb.com/docs/stable/aql/fundamentals-syntax.html#names

相关问题