Skip to content

v0.21.0

Choose a tag to compare

@github-actions github-actions released this 20 Jul 00:25

Migrating to EdgeDB 2.0

We recently released v0.21.0 of the edgedb module on NPM and deno.land/x, which supports the latest EdgeDB 2.0 features and protocol. It is backwards-compatible with v1 instances as well, so we recommend all users upgrade.

npm install edgedb@latest

Breaking changes

  • All uuid properties are now decoded to include hyphens. Previously hyphens were elided for performance reasons; this issue has since been resolved.

    client.querySingle(`select uuid_generate_v1mc();`);
    // "ce13b17a-7fcd-42b3-b5e3-eb28d1b953f6"
  • All json properties and parameters are now parsed/stringified internally by the client. Previously:

    const result = await client.querySingle(
      `select to_json('{"hello": "world"}');`
    );
    result; // '{"hello": "world"}'
    typeof result; // string

    Now:

    const result = await client.querySingle(
      `select to_json('{"hello": "world"}');`
    );
    result; // {hello: "world"}
    typeof result; // object
    result.hello; // "world"

New features

  • Added the .withGlobals method the Client for setting global variables

    import {createClient} from "edgedb";
    const client = createClient().withGlobals({
      current_user: getUserIdFromCookie(),
    });
    
    client.query(`select User { email } filter .id = global current_user;`);
  • Support for globals in the query builder

    const query = e.select(e.User, user => ({
      email: true,
      filter: e.op(user.id, "=", e.global.current_user),
    }));
    
    await query.run(client);
  • Support for the group statement. Docs

    e.group(e.Movie, movie => {
      return {
        title: true,
        actors: {name: true},
        num_actors: e.count(movie.characters),
        by: {release_year: movie.release_year},
      };
    });
    /* [
      {
        key: {release_year: 2008},
        grouping: ["release_year"],
        elements: [{
          title: "Iron Man",
          actors: [...],
          num_actors: 5
        }, {
          title: "The Incredible Hulk",
          actors: [...],
          num_actors: 3
        }]
      },
      // ...
    ] */
  • Support for range types and DateDuration values

Commits: