Light
Dark
System
1.0latest

Objects and Paths

All queries on this page assume the following schema.

Copy
module default {
  type Person {
    required property name -> str;
  }

  abstract type Content {
    required property title -> str {constraint exclusive};
    multi link actors -> Person {
      property character_name -> str;
    };
  }

  type Movie extending Content {
    property release_year -> int64;
  }

  type TVShow extending Content {
    property num_seasons -> int64;
  }
}

All object types in your schema are reflected into the query builder, properly namespaced by module.

Copy
e.default.Person;
e.default.Movie;
e.default.TVShow;
e.my_module.SomeType;

For convenience, the contents of the default module are also available at the top-level of e.

Copy
e.Person;
e.Movie;
e.TVShow;

EdgeQL-style paths are supported on object type references.

Copy
e.Person.name;              // Person.name
e.Movie.title;              // Movie.title
e.TVShow.actors.name;          // Movie.actors.name

Paths can be constructed from any object expression, not just the root types.

Copy
e.select(e.Person).name;
// (select Person).name

e.op(e.Movie, 'union', e.TVShow).actors;
// (Movie union TVShow).actors

const ironMan = e.insert(e.Movie, {
  title: "Iron Man"
});
ironMan.title;
// (insert Movie { title := "Iron Man" }).title

Use the type intersection operator to narrow the type of a set of objects. For instance, to represent the elements of an Account’s watchlist that are of type TVShow:

Copy
e.Person.acted_in.is(e.TVShow);
// Person.acted_in[is TVShow]
Light
Dark
System