View Source EdgeDB.NamedTuple (EdgeDB v0.7.0)
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
Summary
Functions
Get named tuple keys.
Convert a named tuple into a regular map.
Convert a named tuple to a regular erlang tuple.
Types
@opaque t()
An immutable value representing an EdgeDB named tuple value.
Functions
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"]
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]}
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]}