Arcadic.Record (Arcadic v0.7.0)

Copy Markdown View Source

Single-record CRUD over gRPC — create/lookup/update/delete a record by its @rid, working in raw maps (no typed Node/Edge decode; that stays ash_arcadic's job — charter-compatible). A convenience surface over the gRPC CreateRecord/LookupByRid/UpdateRecord/DeleteRecord RPCs; everything here is also reachable via Arcadic.command/query with SQL/Cypher. gRPC-only: an HTTP/Bolt conn returns :not_supported.

{:ok, rid} = Arcadic.Record.create(grpc_conn, "Person", %{"name" => "Ada"})
{:ok, %{"name" => "Ada", "@rid" => ^rid}} = Arcadic.Record.lookup(grpc_conn, rid)
:ok = Arcadic.Record.update(grpc_conn, rid, %{"age" => 36})
:ok = Arcadic.Record.delete(grpc_conn, rid)

Values are encoded value-free (an unencodable value → {:error, :invalid_record}, no echo). update/4 merges properties by default (partial update); replace: true replaces the record.

Summary

Functions

Create a record of type from a property map. Returns {:ok, rid}.

Delete a record by rid. Returns :ok.

Look up a record by rid. Returns {:ok, map} (with @rid/@type), or {:ok, nil} if absent.

Update a record by rid. Merges props (partial); replace: true replaces the record. Returns :ok.

Functions

create(conn, type, props, opts \\ [])

@spec create(Arcadic.Conn.t(), String.t(), map(), keyword()) ::
  {:ok, String.t()} | {:error, atom() | Exception.t()}

Create a record of type from a property map. Returns {:ok, rid}.

delete(conn, rid, opts \\ [])

@spec delete(Arcadic.Conn.t(), String.t(), keyword()) ::
  :ok | {:error, atom() | Exception.t()}

Delete a record by rid. Returns :ok.

lookup(conn, rid, opts \\ [])

@spec lookup(Arcadic.Conn.t(), String.t(), keyword()) ::
  {:ok, map() | nil} | {:error, atom() | Exception.t()}

Look up a record by rid. Returns {:ok, map} (with @rid/@type), or {:ok, nil} if absent.

update(conn, rid, props, opts \\ [])

@spec update(Arcadic.Conn.t(), String.t(), map(), keyword()) ::
  :ok | {:error, atom() | Exception.t()}

Update a record by rid. Merges props (partial); replace: true replaces the record. Returns :ok.