NebulaGraphEx.Record (nebula_graph_ex v0.1.8)

Copy Markdown View Source

A single row in a NebulaGraphEx.ResultSet.

Values are decoded Elixir terms — not raw Thrift tuples. Use get/2 to access a column by name, or get!/2 to raise if the column is absent.

Example

{:ok, rs} = NebulaGraphEx.Graph.query(conn, "MATCH (v:Player) RETURN v.name, v.age")

records = NebulaGraphEx.ResultSet.rows(rs)
Enum.map(records, fn record ->
  name = NebulaGraphEx.Record.get!(record, "v.name")
  age  = NebulaGraphEx.Record.get(record, "v.age")
  %{name: name, age: age}
end)

Summary

Functions

Returns {:ok, value} if the column exists, {:error, :not_found} otherwise.

Returns the decoded value for the given column name, or nil if the column does not exist in this record.

Returns the decoded value for name, raising KeyError if the column is not present.

Converts the record to a plain map keyed by column name.

Types

t()

@type t() :: %NebulaGraphEx.Record{columns: [String.t()], values: [term()]}

Functions

fetch(record, name)

@spec fetch(t(), String.t()) :: {:ok, term()} | {:error, :not_found}

Returns {:ok, value} if the column exists, {:error, :not_found} otherwise.

get(record, name)

@spec get(t(), String.t()) :: term()

Returns the decoded value for the given column name, or nil if the column does not exist in this record.

get!(record, name)

@spec get!(t(), String.t()) :: term()

Returns the decoded value for name, raising KeyError if the column is not present.

to_map(record)

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

Converts the record to a plain map keyed by column name.

Example

NebulaGraphEx.Record.to_map(record)
#=> %{"v.name" => "Tim Duncan", "v.age" => 42}