Objects and Paths

All queries on this page assume the following schema.


1. module default {
2. type Person {
3. required property name -> str;
4. }

6. abstract type Content {
7. required property title -> str {constraint exclusive};
8. multi link actors -> Person {
9. property character_name -> str;
10. };
11. }

13. type Movie extending Content {
14. property release_year -> int64;
15. }

17. type TVShow extending Content {
18. property num_seasons -> int64;
19. }
20. }

Object types

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


1. e.default.Person;
2. e.default.Movie;
3. e.default.TVShow;
4. e.my_module.SomeType;

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


1. e.Person;
2. e.Movie;
3. e.TVShow;

Paths

EdgeQL-style paths are supported on object type references.


1. e.Person.name;              // Person.name
2. e.Movie.title;              // Movie.title
3. e.TVShow.actors.name;          // Movie.actors.name

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


1. e.select(e.Person).name;
2. // (select Person).name

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

7. const ironMan = e.insert(e.Movie, {
8. title: "Iron Man"
9. });
10. ironMan.title;
11. // (insert Movie { title := "Iron Man" }).title

Type intersections

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:


1. e.Person.acted_in.is(e.TVShow);
2. // Person.acted_in[is TVShow]

All possible backlinks are auto-generated and can be auto-completed by TypeScript. They behave just like forward links. However, because they contain special characters, you must use bracket syntax instead of simple dot notation.


1. e.Person["<director[is Movie]"]
2. // Person.<director[is Movie]

For convenience, these backlinks automatically combine the backlink operator and type intersection into a single key. However, the query builder also provides “naked” backlinks; these can be refined with the .is type intersection method.


1. e.Person['<director'].is(e.Movie);
2. // Person.<director[is Movie]