Skip to content

v6.7.0

Choose a tag to compare

@pluma pluma released this 08 Nov 10:02
daa370f

Changed

  • No longer emitting undefined values in aql template strings

    Previously using undefined values 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 aql template strings (#481)

    It is now possible to use aql queries as values in aql template 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 undefined and AQL literals to aql.literal

    Passing undefined to aql.literal will now result in an empty literal as
    would be expected. Passing an AQL literal back into aql.literal will return
    the existing literal rather than the string [object Object].

  • Added aql.join function

    The function aql.join can be used to convert an array of aql queries 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 allowDirtyRead option to db.query and collection.document

    Dirty 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.