Light
Dark
System
1.0latest

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.

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.

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

Copy
scalar type Color extending enum<Red, Green, Blue>;

type Shirt {
  property color -> Color;
}

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 store zero or more primitive values of the same type in an ordered list. Arrays cannot contain object types or other arrays.

Copy
type Person {
  property str_array -> array<str>;
  property json_array -> array<json>;

  # INVALID: arrays of object types not allowed
  # property friends -> array<Person>

  # INVALID: arrays cannot be nested
  # property nested_array -> array<array<str>>
}

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

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.

Copy
type Person {

  property unnamed_tuple -> tuple<str, bool, int64>;
  property nested_tuple -> tuple<tuple<str, tuple<bool, int64>>>;
  property tuple_of_arrays -> tuple<array<str>, array<int64>>;

}

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).

Copy
type BlogPost {
  property metadata -> tuple<title: str, published: bool, upvotes: int64>;
}

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.

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.

Copy
scalar type ticket_number extending sequence;
type Ticket {
  property number -> ticket_number;
}

Reference the Sequence reference for details.

Light
Dark
System