aqlFields.php
Table of Contents
Functions
- aqlFields() : string|null
- Applies AQL filters to a set of fields and returns a string representation suitable for inclusion in an AQL query.
Functions
aqlFields()
Applies AQL filters to a set of fields and returns a string representation suitable for inclusion in an AQL query.
aqlFields(array<string|int, mixed>|null $fields[, string $docRef = AQL::DOC ][, ContainerInterface|null $container = null ][, array<string|int, mixed> $init = [] ][, string|null $edgeRef = null ]) : string|null
This method iterates over the provided fields and applies the corresponding
filter function based on the Field::FILTER option for each field. The
generated expressions are then concatenated into a single string, separated
by ', '.
Supported filters include:
- Scalar fields: BOOL, INT, DATETIME, DEFAULT
- Special fields: TRANSLATE, DISTANCE, REVISION
- Document relations: EDGE, EDGE_SINGLE, EDGE_COUNT, JOIN, JOIN_ARRAY, JOIN_MULTIPLE, UNIQUE_NAME
Each field can also define additional options:
Field::NAME: The target field name in the document (optional)Field::UNIQUE: Unique variable name to use for the AQL expression (optional)Field::QUOTED: Double-quote the output label (for keys that are not bare identifiers, e.g."my-key": …). The attribute access is then reached with backticks (doc.my-key``), the valid AQL form — neverdoc."my-key". AField::NAMEstill overrides the source attribute (only the label is quoted).Field::REQUIRES: Optional permission subject(s) — when present and the request-scoped authorizer denies them, the field is dropped from the projection (read-side gating).Field::ALTERS: Optionalalttransformation chain wrapping the projected value (e.g.["trim","lower"]=>name: LOWER(TRIM(doc.name))). Applied only to the default scalar projection (key: doc.key); ignored on typed/structural filters (BOOL, DATETIME, EDGE, JOIN, …).Field::SCOPE: Optional projection source —Scope::VERTEX(default) reads the field from$docRef,Scope::EDGEreads it from$edgeRef(the traversal edge). The edge scope is only valid inside an edge sub-query (where$edgeRefis provided) and only on filters that project from a reference; it throws otherwise.Scope::EDGEequalsAQL::EDGE, so both forms are interchangeable.
Parameters
- $fields : array<string|int, mixed>|null
-
Array of fields definitions to filter. The array keys are the field identifiers, and the values are arrays of options (filter, name, unique, quoted, requires). If null or empty, the method returns null.
- $docRef : string = AQL::DOC
-
The document reference to use in AQL expressions. Defaults to
AQL::DOC. - $container : ContainerInterface|null = null
-
The optional DI Container reference.
- $init : array<string|int, mixed> = []
-
Optional associative array definition.
- $edgeRef : string|null = null
-
The traversal edge reference, used to project fields flagged with
Field::SCOPE => Scope::EDGE. Only set inside an edge sub-query;nulleverywhere else.
Tags
Return values
string|null —A string containing the filtered fields as AQL expressions,
suitable for use in a RETURN or LET statement. Returns
null if the input $fields is null or empty.