Primitives​

EdgeDB has a robust type system consisting of primitive and object types. Below is a review of EdgeDB’s primitive types; later, these will be used to declare properties on object types.

Scalar types​

str

A variable-length string

bool

Logical boolean (true/false)

int16

16-bit integer

int32

32-bit integer

int64

64-bit integer

float32

32-bit floating point number

float64

64-bit floating point number

bigint

Arbitrary precision integer

decimal

Arbitrary precision number

json

Arbitrary JSON data

uuid

UUID type

bytes

Arbitrary precision number

datetime

Timezone-aware point in time

duration

Absolute time span

cal::local_datetime

Date and time without timezone

cal::local_date

Date type

cal::local_time

Time type

cal::relative_duration

Relative time span

sequence

Auto-incrementing sequence of int64

Custom scalar types can also be declared. For full documentation, see SDL > Scalar types.

Enums​

To represent an enum, declare a custom scalar that extends the abstract enum type.

  1. scalar type Color extending enum<Red, Green, Blue>;
  2. type Shirt {
  3. property color -> Color;
  4. }

To reference enum values inside EdgeQL queries, use dot notation, e.g. Color.Green.

For a full reference on enum types, see the Enum docs.

Arrays​

Arrays store zero or more primitive values of the same type in an ordered list. Arrays cannot contain object types or other arrays.

  1. type Person {
  2. property str_array -> array<str>;
  3. property json_array -> array<json>;
  4. # INVALID: arrays of object types not allowed
  5. # property friends -> array<Person>
  6. # INVALID: arrays cannot be nested
  7. # property nested_array -> array<array<str>>
  8. }

For a full reference on array types, see the Array docs.

Tuples​

Like arrays, tuples are ordered sequences of primitive data. Unlike arrays, each element of a tuple can have a distinct type. Tuples elements can be any type, including primitives, objects, arrays, and other tuples.

  1. type Person {
  2. property unnamed_tuple -> tuple<str, bool, int64>;
  3. property nested_tuple -> tuple<tuple<str, tuple<bool, int64>>>;
  4. property tuple_of_arrays -> tuple<array<str>, array<int64>>;
  5. }

Optionally, you can assign a key to each element of the tuple. Tuples containing explicit keys are known as named tuples. You must assign keys to all elements (or none of them).

  1. type BlogPost {
  2. property metadata -> tuple<title: str, published: bool, upvotes: int64>;
  3. }

Named and unnamed tuples are the same data structure under the hood. You can add, remove, and change keys in a tuple type after it’s been declared. For details, see EdgeQL > Literals > Tuples.

When you query an unnamed tuple using one of EdgeQL’s client libraries, its value is converted to a list/array. When you fetch a named tuple, it is converted into an object/dictionary/hashmap depending on the language.

Sequences​

To represent an auto-incrementing integer property, declare a custom scalar that extends the abstract sequence type. Creating a sequence type initializes a global int64 counter that auto-increments whenever a new object is created. All properties that point to the same sequence type will share the counter.

  1. scalar type ticket_number extending sequence;
  2. type Ticket {
  3. property number -> ticket_number;
  4. }

Reference the Sequence reference for details.