ArangoDB’s devel
branch recently saw a change that makes writing
some AQL queries a bit simpler.
The change introduces an optional shorthand notation for object attributes in the style of ES6’s enhanced object literal notation.
For example, consider the following query that groups values by age
attribute and counts the number of documents per distinct age
value:
1 2 3 |
|
The object declaration in the last line of the query is somewhat redundant because one has to type identical attribute names and values:
1
|
|
In this case, the new shorthand notation simplifies the RETURN
to:
1
|
|
In general, the shorthand notation can be used for all object literals when there is an attribute name that refers to a query variable of the same name.
It can also be mixed with the longer notation, e.g.:
1
|
|