v6.7.0
Changed
-
No longer emitting
undefinedvalues inaqltemplate stringsPreviously using
undefinedvalues in an aql template string would result
in a bind parameter being added with no value, which would always lead to an
error response when ArangoDB executes the query.
Now undefined values will simply be omitted, also easing the conditional
insertion of query fragments. -
Changed experimental Views API
This release updates the experimental support for the Views API to the version
implemented in the ArangoDB 3.4 release candidate. Please note that this API
is still subject to change and may indeed still change until the 3.4.0 GA release. -
Updated TypeScript to version 3
This may result in type signatures that are incompatible with TypeScript 2
being added in future releases (including patch releases).
Added
-
Added nesting support for
aqltemplate strings (#481)It is now possible to use aql queries as values in
aqltemplate strings:function createQuery(flowers, color) { const filter = color ? aql`FILTER flower.color == ${color}` : undefined; return aql`FOR flower IN ${flowers} ${filter} RETURN flower`; } createQuery(db.collection("flowers", "green")); // FOR flower IN @@value0 FILTER @value1 RETURN flower // {"@value0": "flowers", "value1": "green"} createQuery(db.collection("flowers")); // FOR flower IN @@value0 RETURN flower // {"@value0": "flowers"}
Previously aql fragments could only be created with
aql.literal, which
does not support bind parameters:aql.literal("FILTER flower.color == " + JSON.stringify(color)); // Note that we had to rely on JSON.stringify to correctly escape the value // because the value is part of the literal, not a bind parameter
-
Added support for
undefinedand AQL literals toaql.literalPassing undefined to
aql.literalwill now result in an empty literal as
would be expected. Passing an AQL literal back intoaql.literalwill return
the existing literal rather than the string[object Object]. -
Added
aql.joinfunctionThe function
aql.joincan be used to convert an array ofaqlqueries into
a combined query:const users = db.collection("users"); const keys = ["a", "b", "c"]; const fragments = keys.map(key => aql`DOCUMENT(${users}, ${key})`); const combined = aql`[${aql.join(fragments, ", ")}]`; // [DOCUMENT(@@value0, @value1), DOCUMENT(@@value0, @value2), \ // DOCUMENT(@@value0, @value3)] // {"@value0": "users", "value1": "a", "value2": "b", "value3": "c"} const query = aql`FOR user IN ${combined} RETURN user.email`; // FOR user IN [DOCUMENT(@@value0, @value1), DOCUMENT(@@value0, @value2), \ // DOCUMENT(@@value0, @value3)] RETURN user.email // {"@value0": "users", "value1": "a", "value2": "b", "value3": "c"}
-
Added
allowDirtyReadoption todb.queryandcollection.documentDirty reads are supported in leader/follower replication setups and require
ArangoDB 3.4 or later. When performing a request that permits dirty reads,
arangojs will load balance across all know leaders and followers and instruct
ArangoDB to allow responding with stale or dirty response data. Note that
data returned from a dirty read may be out of date or inconsistent.