无法在 ArangoDB 中声明变量
Can't declare a variable in ArangoDB
我正在使用 ArangoDB 3.4.6-1 并想在在线控制台中使用 AQL(如所述 here)删除顶点。
在教程的第一步中,您应该将边保存到一个变量中。在我的例子中,声明如下所示:
LET edgeKeys = (FOR v, e, p IN 1..100 INBOUND 'Node/N3' GRAPH 'graph' RETURN e._key)
For
本身不带括号 returns 正确结果:
[
"E3"
]
然而,运行 带括号的整个语句只会抛出以下错误:
Query: AQL: syntax error, unexpected end of query string near ')' at position 1:83 (while parsing)
我尝试对其他图形或其他返回值和对象使用类似的命令,但总是得到相同的错误。
到目前为止,我无法在网上找到合适的解决方案。本教程提供了以下示例代码(复制1:1):
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
而且我遇到了完全相同的错误,它甚至无法检查集合。
我做错了什么?
仅使用 LET
定义变量不是有效的 AQL 语句。
An AQL query must either return a result (indicated by usage of the
RETURN keyword) or execute a data-modification operation (indicated by
usage of one of the keywords INSERT, UPDATE, REPLACE, REMOVE or
UPSERT). The AQL parser will return an error if it detects more than
one data-modification operation in the same query or if it cannot
figure out if the query is meant to be a data retrieval or a
modification operation.
使用本教程中所述的完整 AQL 块,执行工作按预期进行,因为在这种情况下查询正在使用 REMOVE
执行数据修改。 LET
变量声明中的 RETURN
操作不足以 运行 AQL 查询。删除 LET
操作时,查询也能正常工作,因为在这种情况下,AQL 查询直接 returns 结果。
完成 AQL 查询:
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
LET r = (FOR key IN edgeKeys REMOVE key IN knows)
REMOVE 'eve' IN persons
额外的 RETURN 也使查询有效:
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
RETURN edgeKeys
我正在使用 ArangoDB 3.4.6-1 并想在在线控制台中使用 AQL(如所述 here)删除顶点。
在教程的第一步中,您应该将边保存到一个变量中。在我的例子中,声明如下所示:
LET edgeKeys = (FOR v, e, p IN 1..100 INBOUND 'Node/N3' GRAPH 'graph' RETURN e._key)
For
本身不带括号 returns 正确结果:
[
"E3"
]
然而,运行 带括号的整个语句只会抛出以下错误:
Query: AQL: syntax error, unexpected end of query string near ')' at position 1:83 (while parsing)
我尝试对其他图形或其他返回值和对象使用类似的命令,但总是得到相同的错误。
到目前为止,我无法在网上找到合适的解决方案。本教程提供了以下示例代码(复制1:1):
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
而且我遇到了完全相同的错误,它甚至无法检查集合。 我做错了什么?
仅使用 LET
定义变量不是有效的 AQL 语句。
An AQL query must either return a result (indicated by usage of the RETURN keyword) or execute a data-modification operation (indicated by usage of one of the keywords INSERT, UPDATE, REPLACE, REMOVE or UPSERT). The AQL parser will return an error if it detects more than one data-modification operation in the same query or if it cannot figure out if the query is meant to be a data retrieval or a modification operation.
使用本教程中所述的完整 AQL 块,执行工作按预期进行,因为在这种情况下查询正在使用 REMOVE
执行数据修改。 LET
变量声明中的 RETURN
操作不足以 运行 AQL 查询。删除 LET
操作时,查询也能正常工作,因为在这种情况下,AQL 查询直接 returns 结果。
完成 AQL 查询:
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
LET r = (FOR key IN edgeKeys REMOVE key IN knows)
REMOVE 'eve' IN persons
额外的 RETURN 也使查询有效:
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
RETURN edgeKeys