Search
ctrl/
Ask AI
Light
Dark
System

API/EdgeDB types

An immutable representation of an object instance returned from a query.

EdgeDB.Object implements Access behavior to access properties by key.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
object =
 EdgeDB.query_required_single!(client, """
  select schema::ObjectType{
    name
  }
  filter .name = 'std::Object'
  limit 1
 """)
#EdgeDB.Object<name := "std::Object">
Copy
iex(3)> 
object[:name]
"std::Object"
Copy
@type EdgeDB.Object.fields_option() ::
  {:properties, boolean()}
  | {:links, boolean()}
  | {:link_properties, boolean()}
  | {:id, boolean()}
  | {:implicit, boolean()}

Options for EdgeDB.Object.fields/2

Supported options:

  • :properties - flag to include object properties in returning list. The default is true.

  • :links - flag to include object links in returning list. The default is true.

  • :link_properies - flag to include object link properties in returning list. The default is true.

  • :id - flag to include implicit :id in returning list. The default is false.

  • :implicit - flag to include implicit fields (like :id or :__tid__) in returning list. The default is false.

Copy
@type EdgeDB.Object.properties_option() :: {:id, boolean()} | {:implicit, boolean()}

Options for EdgeDB.Object.properties/2

Supported options:

  • :id - flag to include implicit :id in returning list. The default is false.

  • :implicit - flag to include implicit properties (like :id or :__tid__) in returning list. The default is false.

Copy
@opaque EdgeDB.Object.t()

An immutable representation of an object instance returned from a query.

Copy
@type EdgeDB.Object.uuid() :: String.t()

UUID value.

Copy
@spec EdgeDB.Object.fields(t(), [fields_option()]) :: [String.t()]

Get object fields names (properties, links and link propries) as list of strings.

See EdgeDB.Object.fields_option/0 for supported options.

Copy
@spec EdgeDB.Object.id(t()) :: uuid() | nil

Get an object ID if it was returned from the query.

Copy
@spec EdgeDB.Object.properties(t(), [properties_option()]) :: [String.t()]

Get object properties names as list.

See EdgeDB.Object.properties_option/0 for supported options.

Copy
@spec EdgeDB.Object.to_map(t()) :: %{required(String.t()) => term()}

Convert an object into a regular map.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
object =
 EdgeDB.query_required_single!(client, """
  select schema::Property {
      name,
      annotations: {
        name,
        @value
      }
  }
  filter .name = 'listen_port' and .source.name = 'cfg::Config'
  limit 1
 """)
Copy
iex(3)> 
EdgeDB.Object.to_map(object)
%{"name" => "listen_port", "annotations" => [%{"name" => "cfg::system", "@value" => "true"}]}

A representation of an immutable set of values returned by a query. Nested sets in the result are also returned as EdgeDB.Set objects.

EdgeDB.Set implements Enumerable protocol for iterating over set values.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
...(2)> 
set =
 EdgeDB.query!(client, """
  select schema::ObjectType{
    name
  }
  filter .name IN {'std::BaseObject', 'std::Object', 'std::FreeObject'}
  order by .name
 """)
Copy
iex(3)> 
set
#EdgeDB.Set<{#EdgeDB.Object<name := "std::BaseObject">, #EdgeDB.Object<name := "std::FreeObject">, #EdgeDB.Object<name := "std::Object">}>
Copy
@opaque EdgeDB.Set.t()

A representation of an immutable set of values returned by a query.

Copy
@spec EdgeDB.Set.empty?(t()) :: boolean()

Check if set is empty.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
set = EdgeDB.query!(client, "select v1::Ticket")
Copy
iex(3)> 
EdgeDB.Set.empty?(set)
true

An immutable value representing an EdgeDB named tuple value.

EdgeDB.NamedTuple implements Access behavior to access fields by index or key and Enumerable protocol for iterating over tuple values.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
nt = EdgeDB.query_required_single!(client, "select (a := 1, b := 'a', c := [3])")
#EdgeDB.NamedTuple<a: 1, b: "a", c: [3]>
Copy
iex(3)> 
nt[:b]
"a"
Copy
iex(4)> 
nt["c"]
[3]
Copy
iex(4)> 
nt[0]
1
Copy
@opaque EdgeDB.NamedTuple.t()

An immutable value representing an EdgeDB named tuple value.

Copy
@spec EdgeDB.NamedTuple.keys(t()) :: [String.t()]

Get named tuple keys.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
nt = EdgeDB.query_required_single!(client, "select (a := 1, b := 'a', c := [3])")
Copy
iex(3)> 
EdgeDB.NamedTuple.keys(nt)
["a", "b", "c"]
Copy
@spec EdgeDB.NamedTuple.to_map(t()) :: %{required(String.t()) => term()}

Convert a named tuple into a regular map.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
nt = EdgeDB.query_required_single!(client, "select (a := 1, b := 'a', c := [3])")
Copy
iex(3)> 
EdgeDB.NamedTuple.to_map(nt)
%{"a" => 1, "b" => "a", "c" => [3]}
Copy
@spec EdgeDB.NamedTuple.to_tuple(t()) :: tuple()

Convert a named tuple to a regular erlang tuple.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
nt = EdgeDB.query_required_single!(client, "select (a := 1, b := 'a', c := [3])")
Copy
iex(3)> 
EdgeDB.NamedTuple.to_tuple(nt)
{1, "a", [3]}

An immutable value represeting an EdgeDB cal::relative_duration value.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
EdgeDB.query_required_single!(client, "select <cal::relative_duration>'45.6 seconds'")
#EdgeDB.RelativeDuration<"PT45.6S">
Copy
@type EdgeDB.RelativeDuration.t() :: %EdgeDB.RelativeDuration{
  days: pos_integer(),
  microseconds: pos_integer(),
  months: pos_integer()
}

An immutable value represeting an EdgeDB cal::relative_duration value.

Fields:

  • :months - number of months.

  • :days - number of days.

  • :microseconds - number of microseconds.

An immutable value represeting an EdgeDB cal::date_duration value.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
EdgeDB.query_required_single!(client, "select <cal::date_duration>'1 year 2 days'")
#EdgeDB.DateDuration<"P1Y2D">
Copy
@type EdgeDB.DateDuration.t() :: %EdgeDB.DateDuration{days: integer(), months: integer()}

An immutable value represeting an EdgeDB cal::date_duration value.

Fields:

  • :days - number of days.

  • :months - number of months.

An immutable value represeting an EdgeDB cfg::memory value as a quantity of memory storage.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
mem = EdgeDB.query_required_single!(client, "select <cfg::memory>'5KiB'")
#EdgeDB.ConfigMemory<"5KiB">
Copy
iex(3)> 
EdgeDB.ConfigMemory.bytes(mem)
5120
Copy
@opaque EdgeDB.ConfigMemory.t()

An immutable value represeting an EdgeDB cfg::memory value as a quantity of memory storage.

Copy
@spec EdgeDB.ConfigMemory.bytes(t()) :: pos_integer()

Get a quantity of memory storage in bytes.

Copy
@spec EdgeDB.ConfigMemory.new(non_neg_integer()) :: t()

Create a new config memory value.

A value representing some interval of values.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
EdgeDB.query_required_single!(client, "select range(1, 10)")
#EdgeDB.Range<[1, 10)>
Copy
@type EdgeDB.Range.creation_option() :: {:inc_lower, boolean()} | {:inc_upper, boolean()} | {:empty, boolean()}

Options for EdgeDB.Range.new/3 function.

Supported options:

  • :inc_lower - flag whether the created range should strictly include the lower boundary.

  • :inc_upper - flag whether the created range should strictly include the upper boundary.

  • :empty - flag to create an empty range.

Copy
@type EdgeDB.Range.t() :: t(value())

A value of EdgeDB.Range.value/0 type representing some interval of values.

Copy
@type EdgeDB.Range.t(value) :: %EdgeDB.Range{
  inc_lower: boolean(),
  inc_upper: boolean(),
  is_empty: boolean(),
  lower: value | nil,
  upper: value | nil
}

A value of EdgeDB.Range.value/0 type representing some interval of values.

Fields:

  • :lower - data for the lower range boundary.

  • :upper - data for the upper range boundary.

  • :inc_lower - flag whether the range should strictly include the lower boundary.

  • :inc_upper - flag whether the range should strictly include the upper boundary.

  • :is_empty - flag for an empty range.

Copy
@type EdgeDB.Range.value() :: integer() | float() | Decimal.t() | DateTime.t() | NaiveDateTime.t() | Date.t()

A type that is acceptable by EdgeDB ranges.

Copy
@spec EdgeDB.Range.empty() :: t()

Create an empty range.

Copy
iex(1)> 
EdgeDB.Range.empty()
#EdgeDB.Range<empty>
Copy
@spec EdgeDB.Range.new(value | nil, value | nil, [creation_option()]) :: t(value) when value: value()

Create new range.

Copy
iex(1)> 
EdgeDB.Range.new(1.1, 3.3, inc_upper: true)
#EdgeDB.Range<[1.1, 3.3]>

A value representing a collection of ranges.

EdgeDB.MultiRange implements Enumerable protocol for iterating over the collection. Each range in the collection is an instance of the EdgeDB.Range.t/0 struct.

Copy
iex(1)> 
{:ok, client} = EdgeDB.start_link()
Copy
iex(2)> 
EdgeDB.query_required_single!(client, "select multirange([range(1, 10)])")
#EdgeDB.MultiRange<[#EdgeDB.Range<[1, 10)>]>
Copy
@type EdgeDB.MultiRange.t() :: t(value())

A value of EdgeDB.MultiRange.value/0 type representing a collection of intervals of values.

Copy
@opaque EdgeDB.MultiRange.t(value)

A value of EdgeDB.MultiRange.value/0 type representing a collection of intervals of values.

Copy
@type EdgeDB.MultiRange.value() :: EdgeDB.Range.value()

A type that is acceptable by EdgeDB ranges.

Copy
@spec EdgeDB.MultiRange.new() :: t()

Create a new multirange.

Copy
@spec EdgeDB.MultiRange.new(Enumerable.t(EdgeDB.Range.t(v))) :: t(v) when v: value()

Create a new multirange from enumerable.