View Source EdgeDB.NamedTuple (EdgeDB v0.1.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, pid} = EdgeDB.start_link()
iex(2)> nt = EdgeDB.query_required_single!(pid, "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
Link to this section Summary
Link to this section Types
Specs
t()
An immutable value representing an EdgeDB named tuple value.
Link to this section Functions
Specs
Get named tuple keys
iex(1)> {:ok, pid} = EdgeDB.start_link()
iex(2)> nt = EdgeDB.query_required_single!(pid, "SELECT (a := 1, b := 'a', c := [3])")
iex(3)> EdgeDB.NamedTuple.keys(nt)
["a", "b", "c"]
Specs
Convert a named tuple to a regular erlang tuple.
iex(1)> {:ok, pid} = EdgeDB.start_link()
iex(2)> nt = EdgeDB.query_required_single!(pid, "SELECT (a := 1, b := 'a', c := [3])")
iex(3)> EdgeDB.NamedTuple.to_tuple(nt)
{1, "a", [3]}