User-defined functions
User-defined functions (UDFs) allow developers to combine built-in or user-defined FQL functions into named queries that you can execute repeatedly.
By default, UDFs run with the privileges of the current query session.
For example, if your client code connects to Fauna using a key with
the server role, any called UDFs
run with server
privileges by default. When you assign a specific
role to a UDF, the UDF executes with the assigned role’s privileges
which can differ from the caller’s.
Limitations
-
Fauna imposes a 30-second transaction timeout, terminating any transactions that exceed the limit. Transaction termination can happen with UDFs that take too long to execute.
-
Fauna terminates transactions when the execution of a UDF exceeds available memory.
-
Recursion is possible but is limited to a depth of 200 calls.
-
In some contexts, such as within index bindings, using "server read-only" keys, or attribute-based access control, Fauna may restrict UDFs from performing write or read operations.