ArangoDB Manual Pages
AQL comes with a built-in set of functions, but it is no full-feature programming language.
In order to avoid conflicts with existing or future built-in function names, all user functions must be put into separate namespaces. Invoking a user functions is then possible by referring to the fully-qualified function name, which includes the namespace, too.
: symbol is used inside AQL as the namespace separator. Using the namespace separator, users can create a multi-level hierarchy of function groups if required.
RETURN myfunctions::myfunc() RETURN myfunctions::math::random()
Note: as all function names in AQL, user function names are also case-insensitive.
Built-in AQL functions reside in the namespace
_aql, which is also the default namespace to look in if an unqualified function name is found. Adding user functions to the
_aql namespace is disallowed and will fail.
User functions can take any number of input arguments and should provide one result. They should be kept purely functional and thus free of side effects and state.
Especially it is unsupported to modify any global variables, or to change data of a collection from an AQL user function.
User function code is late-bound, and may thus not rely on any variables that existed at the time of declaration. If user function code requires access to any external data, it must take care to set up the data by itself.
User functions must only return primitive types (i.e.
AQL user functions can be registered using the
aqlfunctions object as follows:
var aqlfunctions = require("org/arangodb/aql/functions");
To register a function, the fully qualified function name plus the function code must be specified.
It is possible to unregister a single user function, or a whole group of user functions (identified by their namespace) in one go:
To get an overview of which functions are currently registered, the
toArray function can be used:
ExamplesTo list all available user functions: