[英]ArangoDB running multiple queries
I want to run more than one query .. how to do it?我想运行多个查询..怎么做?
eg, I have below two queries -例如,我有以下两个查询 -
FOR doc IN users
RETURN doc
FOR doc IN users
RETURN { user: doc, newAttribute: true }
If I have to run both queries I have to run them separately, is there a way to execute a script or I need to put a semicolon at the end like SQL and run it.如果我必须运行两个查询,我必须分别运行它们,有没有办法执行脚本,或者我需要像 SQL 一样在末尾放一个分号并运行它。
Can I use arangosh?我可以使用 arangosh 吗?
You can use LET
to execute multiple sub-queries in a single queries:您可以使用LET
在单个查询中执行多个子查询:
LET firstUserResult = (
FOR doc IN users
RETURN doc
)
LET secondUserResult = (
FOR doc IN users
RETURN { user: doc, newAttribute: true }
)
RETURN { first: firstUserResult, second: secondUserResult }
Some notes here - you will need to add an additional RETURN
statement at the end of the query.这里有一些注意事项 - 您需要在查询的末尾添加一个额外的RETURN
语句。 This will definitely work for reads but you may run into issues when trying to write in multiple queries.这肯定适用于读取,但在尝试写入多个查询时可能会遇到问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.