# `NebulaGraphEx.ResultSet`
[🔗](https://github.com/VChain/nebula_graph_ex/blob/v0.1.8/lib/nebula_graph_ex/result_set.ex#L1)

A decoded NebulaGraph result set with a convenient row/column API.

`NebulaGraphEx.Graph.query/4` returns a `%ResultSet{}` on success. Each row
is a `%NebulaGraphEx.Record{}` with fully decoded Elixir values.

## Example

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

    rs |> NebulaGraphEx.ResultSet.columns()
    #=> ["v.name", "v.age"]

    rs |> NebulaGraphEx.ResultSet.count()
    #=> 3

    rs |> NebulaGraphEx.ResultSet.rows() |> Enum.map(&NebulaGraphEx.Record.to_map/1)
    #=> [%{"v.name" => "Tim Duncan", "v.age" => 42}, ...]

# `t`

```elixir
@type t() :: %NebulaGraphEx.ResultSet{
  columns: [String.t()],
  comment: String.t() | nil,
  latency_us: non_neg_integer(),
  num_rows: non_neg_integer(),
  rows: [NebulaGraphEx.Record.t()],
  space_name: String.t() | nil,
  statement: String.t()
}
```

# `columns`

```elixir
@spec columns(t()) :: [String.t()]
```

Returns the ordered list of column name strings.

# `count`

```elixir
@spec count(t()) :: non_neg_integer()
```

Returns the number of rows in the result set.

# `empty?`

```elixir
@spec empty?(t()) :: boolean()
```

Returns `true` if the result set has no rows.

# `first`

```elixir
@spec first(t()) :: NebulaGraphEx.Record.t() | nil
```

Returns the first `%Record{}`, or `nil` if the result set is empty.

# `first!`

```elixir
@spec first!(t()) :: NebulaGraphEx.Record.t()
```

Returns the first `%Record{}`, raising `RuntimeError` if the result is empty.

# `latency_us`

```elixir
@spec latency_us(t()) :: non_neg_integer()
```

Server-side execution latency in microseconds.

# `map`

```elixir
@spec map(t(), (NebulaGraphEx.Record.t() -&gt; term())) :: [term()]
```

Maps a function over every row. Equivalent to `Enum.map(rows(rs), fun)`.

# `one!`

```elixir
@spec one!(t()) :: NebulaGraphEx.Record.t()
```

Returns the single row, raising if there is not exactly one.

# `rows`

```elixir
@spec rows(t()) :: [NebulaGraphEx.Record.t()]
```

Returns all rows as a list of `%NebulaGraphEx.Record{}` structs.

# `to_maps`

```elixir
@spec to_maps(t()) :: [%{required(String.t()) =&gt; term()}]
```

Returns all rows as a list of plain maps (`%{column_name => value}`).

Convenient for JSON serialisation or pattern matching on column names.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
