Marks an arbitrary scalar value (i.e. a string, number or boolean) as
safe for being inlined directly into AQL queries when used in an aql
template string, rather than being converted into a bind parameter.
Note: Nesting aql template strings is a much safer alternative for
most use cases. This low-level helper function only exists to help with
rare edge cases where a trusted AQL query fragment must be read from a
string (e.g. when reading query fragments from JSON) and should only be
used as a last resort.
Example
// BAD! DO NOT DO THIS! constsortDirection = literal('ASC');
// GOOD! DO THIS INSTEAD! constsortDirection = aql`ASC`;
Example
// BAD! DO NOT DO THIS! constfilterColor = literal('FILTER d.color == "green"'); constresult = awaitdb.query(aql` FOR d IN some-collection ${filterColor} RETURN d `);
// GOOD! DO THIS INSTEAD! constcolor = "green"; constfilterColor = aql`FILTER d.color === ${color}`; constresult = awaitdb.query(aql` FOR d IN some-collection ${filterColor} RETURN d `);
Example
// WARNING: We explicitly trust the environment variable to be safe! constfilter = literal(process.env.FILTER_STATEMENT); constusers = awaitdb.query(aql` FOR user IN users ${filter} RETURN user `);
Marks an arbitrary scalar value (i.e. a string, number or boolean) as safe for being inlined directly into AQL queries when used in an
aql
template string, rather than being converted into a bind parameter.Note: Nesting
aql
template strings is a much safer alternative for most use cases. This low-level helper function only exists to help with rare edge cases where a trusted AQL query fragment must be read from a string (e.g. when reading query fragments from JSON) and should only be used as a last resort.Example
Example
Example