RETURN statement can be used to produce the result of a query. It is mandatory to specify a
RETURN statement at the end of each block in a data-selection query, otherwise the query will be invalid. Using
RETURN on the main level in data-modification queries is optional.
The general syntax for
The expression returned by
RETURN is produced for each iteration in the block the
RETURN statement is placed in. That means the result of a
RETURN statement is always an array when inside
To return all elements from the currently iterated array without modification, the following simple form can be used:
RETURN allows specifying an expression, arbitrary computations can be performed to calculate the result elements. Any of the variables valid in the scope the
RETURN is placed in can be used for the computations.
To iterate over all elements of an array of objects and return the full objects, you can write:
In each iteration of the for-loop, an element of the array is assigned to a variable
i and returned unmodified in this example. To return only one attribute of each element, you could use a different return expression:
Or to return multiple attributes, an object can be constructed like this:
Dynamic attribute names are supported as well: