问题描述
可能是一个愚蠢的问题,但如果在集合中我有包含用空格定义的属性的文档,例如:
{
"attribute with spaces" : "blabla",...
}
如何查询才能找到它?我试过了
for document in documents
filter document."attribute with spaces" == "blabla"
但我当然会遇到语法错误。
解决方法
作为保留关键字或包含空格或属性名称中不允许的其他字符的属性名称必须用反引号引用:
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