Light
Dark
System

Aliases

This section assumes a basic understanding of EdgeQL. If you aren’t familiar with it, feel free to skip this page for now.

An alias is a pointer to a set of values. This set is defined with an arbitrary EdgeQL expression.

Like computed properties, this expression is evaluated on the fly whenever the alias is referenced in a query. Unlike computed properties, aliases are defined independent of an object type; they are standalone expressions.

Scalar alias

Copy
alias digits := {0,1,2,3,4,5,6,7,8,9};

Object type alias

The name of a given object type (e.g. User) is itself a pointer to the set of all User objects. After declaring the alias below, you can use User and UserAlias interchangably.

Copy
alias UserAlias := User;

Object type alias with computeds

Object type aliases can include a shape that declare additional computed properties or links.

Copy
type Post {
  required property title -> str;
}

alias PostAlias := Post {
  trimmed_title := str_trim(.title)
}

In effect, this creates a virtual subtype of the base type, which can be referenced in queries just like any other type.

Query alias

Aliases can correspond to an arbitrary EdgeQL expression, including entire queries.

Copy
type BlogPost {
  required property title -> str;
  required property is_published -> bool;
}

alias PublishedPosts := (
  select BlogPost
  filter .is_published = true
);

All aliases are reflected in the database’s built-in GraphQL schema.

Light
Dark
System