AQL queries without collections

You can use AQL with only expressions and no document access for some calculation and testing purposes

AQL queries typically access one or more collections to read from documents or to modify them. Queries don’t necessarily have to involve collections however. Below are a few examples of that.

Following is a query that returns a string value. The result string is contained in an array because the result of every valid query is an array:

RETURN "this will be returned"
Show output

You may use variables, call functions and return arbitrarily structured results:

LET array = [1, 2, 3, 4]
RETURN { array, sum: SUM(array) }
Show output

Language constructs such as the FOR loop can be used too. Below query creates the Cartesian product of two arrays and concatenates the value pairs:

FOR year IN [ 2011, 2012, 2013 ]
  FOR quarter IN [ 1, 2, 3, 4 ]
    RETURN {
      year,
      quarter,
      formatted: CONCAT(quarter, " / ", year)
    }
Show output