An immutable representation of an object instance returned from a query.
EdgeDB.Object
implements Access
behavior to access properties by key.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> object =
...(2)> EdgeDB.query_required_single!(client, """
...(2)> select schema::ObjectType{
...(2)> name
...(2)> }
...(2)> filter .name = 'std::Object'
...(2)> limit 1
...(2)> """)
#EdgeDB.Object<name := "std::Object">
iex(3)> object[:name]
"std::Object"
In EdgeDB, objects can have links to other objects or a set of objects. You can use the same syntax to access links values as for object properties. Links can also have their own properties (denoted as @<link_prop_name>
in EdgeQL syntax). You can use the same property name as in the query to access them from the links.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> object =
...(2)> EdgeDB.query_required_single!(client, """
...(2)> select schema::Property {
...(2)> name,
...(2)> annotations: {
...(2)> name,
...(2)> @value
...(2)> }
...(2)> }
...(2)> filter .name = 'listen_port' and .source.name = 'cfg::Config'
...(2)> limit 1
...(2)> """)
#EdgeDB.Object<name := "listen_port", annotations := #EdgeDB.Set<{#EdgeDB.Object<name := "cfg::system", @value := "true">}>>
iex(3)> annotations = object[:annotations]
#EdgeDB.Set<{#EdgeDB.Object<name := "cfg::system", @value := "true">}>
iex(4)> link = Enum.at(annotations, 0)
#EdgeDB.Object<name := "cfg::system", @value := "true">
iex(5)> link["@value"]
"true"
@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 istrue
.:links
- flag to include object links in returning list. The default istrue
.:link_properies
- flag to include object link properties in returning list. The default istrue
.:id
- flag to include implicit:id
in returning list. The default isfalse
.:implicit
- flag to include implicit fields (like:id
or:__tid__
) in returning list. The default isfalse
.
@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 isfalse
.:implicit
- flag to include implicit properties (like:id
or:__tid__
) in returning list. The default isfalse
.
@opaque EdgeDB.Object.t()
An immutable representation of an object instance returned from a query.
@type EdgeDB.Object.uuid() :: String.t()
UUID value.
@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.
@spec EdgeDB.Object.id(t()) :: uuid() | nil
Get an object ID if it was returned from the query.
@spec EdgeDB.Object.link_properties(t()) :: [String.t()]
Get object link propeties names as list.
@spec EdgeDB.Object.links(t()) :: [String.t()]
Get object links names as list.
@spec EdgeDB.Object.properties(t(), [properties_option()]) :: [String.t()]
Get object properties names as list.
See EdgeDB.Object.properties_option/0
for supported options.
@spec EdgeDB.Object.to_map(t()) :: %{required(String.t()) => term()}
Convert an object into a regular map.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> object =
...(2)> EdgeDB.query_required_single!(client, """
...(2)> select schema::Property {
...(2)> name,
...(2)> annotations: {
...(2)> name,
...(2)> @value
...(2)> }
...(2)> }
...(2)> filter .name = 'listen_port' and .source.name = 'cfg::Config'
...(2)> limit 1
...(2)> """)
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.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> set =
...(2)> EdgeDB.query!(client, """
...(2)> select schema::ObjectType{
...(2)> name
...(2)> }
...(2)> filter .name IN {'std::BaseObject', 'std::Object', 'std::FreeObject'}
...(2)> order by .name
...(2)> """)
iex(3)> set
#EdgeDB.Set<{#EdgeDB.Object<name := "std::BaseObject">, #EdgeDB.Object<name := "std::FreeObject">, #EdgeDB.Object<name := "std::Object">}>
@opaque EdgeDB.Set.t()
A representation of an immutable set of values returned by a query.
@spec EdgeDB.Set.empty?(t()) :: boolean()
Check if set is empty.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> set = EdgeDB.query!(client, "select v1::Ticket")
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.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> nt = EdgeDB.query_required_single!(client, "select (a := 1, b := 'a', c := [3])")
#EdgeDB.NamedTuple<a: 1, b: "a", c: [3]>
iex(3)> nt[:b]
"a"
iex(4)> nt["c"]
[3]
iex(4)> nt[0]
1
@opaque EdgeDB.NamedTuple.t()
An immutable value representing an EdgeDB named tuple value.
@spec EdgeDB.NamedTuple.keys(t()) :: [String.t()]
Get named tuple keys.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> nt = EdgeDB.query_required_single!(client, "select (a := 1, b := 'a', c := [3])")
iex(3)> EdgeDB.NamedTuple.keys(nt)
["a", "b", "c"]
@spec EdgeDB.NamedTuple.to_map(t()) :: %{required(String.t()) => term()}
Convert a named tuple into a regular map.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> nt = EdgeDB.query_required_single!(client, "select (a := 1, b := 'a', c := [3])")
iex(3)> EdgeDB.NamedTuple.to_map(nt)
%{"a" => 1, "b" => "a", "c" => [3]}
@spec EdgeDB.NamedTuple.to_tuple(t()) :: tuple()
Convert a named tuple to a regular erlang tuple.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> nt = EdgeDB.query_required_single!(client, "select (a := 1, b := 'a', c := [3])")
iex(3)> EdgeDB.NamedTuple.to_tuple(nt)
{1, "a", [3]}
An immutable value represeting an EdgeDB cal::relative_duration
value.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> EdgeDB.query_required_single!(client, "select <cal::relative_duration>'45.6 seconds'")
#EdgeDB.RelativeDuration<"PT45.6S">
@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.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> EdgeDB.query_required_single!(client, "select <cal::date_duration>'1 year 2 days'")
#EdgeDB.DateDuration<"P1Y2D">
@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.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> mem = EdgeDB.query_required_single!(client, "select <cfg::memory>'5KiB'")
#EdgeDB.ConfigMemory<"5KiB">
iex(3)> EdgeDB.ConfigMemory.bytes(mem)
5120
@opaque EdgeDB.ConfigMemory.t()
An immutable value represeting an EdgeDB cfg::memory
value as a quantity of memory storage.
@spec EdgeDB.ConfigMemory.bytes(t()) :: pos_integer()
Get a quantity of memory storage in bytes.
@spec EdgeDB.ConfigMemory.new(non_neg_integer()) :: t()
Create a new config memory value.
A value representing some interval of values.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> EdgeDB.query_required_single!(client, "select range(1, 10)")
#EdgeDB.Range<[1, 10)>
@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.
@type EdgeDB.Range.t() :: t(value())
A value of EdgeDB.Range.value/0
type representing some interval of values.
@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.
@type EdgeDB.Range.value() :: integer() | float() | Decimal.t() | DateTime.t() | NaiveDateTime.t() | Date.t()
A type that is acceptable by EdgeDB ranges.
@spec EdgeDB.Range.empty() :: t()
Create an empty range.
iex(1)> EdgeDB.Range.empty()
#EdgeDB.Range<empty>
@spec EdgeDB.Range.new(value | nil, value | nil, [creation_option()]) :: t(value) when value: value()
Create new range.
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.
iex(1)> {:ok, client} = EdgeDB.start_link()
iex(2)> EdgeDB.query_required_single!(client, "select multirange([range(1, 10)])")
#EdgeDB.MultiRange<[#EdgeDB.Range<[1, 10)>]>
@type EdgeDB.MultiRange.t() :: t(value())
A value of EdgeDB.MultiRange.value/0
type representing a collection of intervals of values.
@opaque EdgeDB.MultiRange.t(value)
A value of EdgeDB.MultiRange.value/0
type representing a collection of intervals of values.
@type EdgeDB.MultiRange.value() :: EdgeDB.Range.value()
A type that is acceptable by EdgeDB ranges.
@spec EdgeDB.MultiRange.new() :: t()
Create a new multirange.
@spec EdgeDB.MultiRange.new(Enumerable.t(EdgeDB.Range.t(v))) :: t(v) when v: value()
Create a new multirange from enumerable.