Objects and paths
All queries on this page assume the following schema.
1. module default {
2. type Account {
3. required property username -> str {
4. constraint exclusive;
5. };
6. multi link watchlist -> Media;
7. }
9. type Person {
10. required property name -> str;
11. }
13. abstract type Media {
14. required property title -> str;
15. multi link cast -> Person {
16. property character_name -> str;
17. };
18. }
20. type Movie extending Media {
21. property runtime -> duration;
22. }
24. type TVShow extending Media {
25. property number_of_seasons -> int64;
26. }
27. }
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.cast.name; // Movie.cast.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).cast;
5. // (Movie union TVShow).cast
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]
Backlinks
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["<directed[is Movie]"]
2. // Person.<directed[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['<directed'].is(e.Movie);
2. // Person.<directed[is Movie]
