Arcadic.Result (Arcadic v0.7.0)

Copy Markdown View Source

Normalizes an ArcadeDB command/query response envelope into a list of rows.

Strips @props (serializer noise on projection rows) but KEEPS the record and graph identity keys the data layer needs: @rid, @type, @cat ("v"/"e"), @in, @out (edges only). Probe-verified — spec §15 P4/P5/P15.

An EXPLAIN/PROFILE envelope carries its plan under explainPlan (never result), so normalize/1 returns {:error, %Arcadic.Error{reason: :use_explain}} for it rather than a silent empty row set. The plan surface is normalize_plan/1, consumed by Arcadic.explain/4 and Arcadic.profile/4.

Summary

Functions

Extract result, strip @props per row; return {:ok, rows}.

Extract the EXPLAIN/PROFILE plan envelope: {:ok, %{plan, plan_tree, rows}}.

Functions

normalize(body)

@spec normalize(map()) :: {:ok, [map()]} | {:error, Arcadic.Error.t()}

Extract result, strip @props per row; return {:ok, rows}.

Examples

iex> Arcadic.Result.normalize(%{"result" => [%{"n" => 1, "@props" => "n:1"}]})
{:ok, [%{"n" => 1}]}

normalize_plan(body)

@spec normalize_plan(map()) ::
  {:ok, %{plan: String.t(), plan_tree: map(), rows: [map()]}}

Extract the EXPLAIN/PROFILE plan envelope: {:ok, %{plan, plan_tree, rows}}.

Examples

iex> Arcadic.Result.normalize_plan(%{"explain" => "plan", "explainPlan" => %{}, "result" => []})
{:ok, %{rows: [], plan: "plan", plan_tree: %{}}}