AshArcadic

CI Hex version HexDocs REUSE status License: MIT

AshArcadic is the Ash Framework data layer for ArcadeDB. Define Ash resources backed by an ArcadeDB graph and use Ash actions to read and write them.

Installation

In a project with Igniter, run mix igniter.install ash_arcadic to create a client and configure Ash setup aliases. For manual installation, add the dependency and run mix deps.get.

{:ash_arcadic, "~> 4.1"}

Example

Set config :ash, default_string_length_count: :codepoints if your application has no string-length rule. Register MyApp.Graph in the application's :ash_domains config. Use an existing ArcadeDB database. Set ARCADEDB_URL, ARCADEDB_DATABASE, ARCADEDB_USERNAME, and ARCADEDB_PASSWORD in the application's environment.

defmodule MyApp.GraphClient do
  @behaviour AshArcadic.Client

  @impl true
  def conn do
    Arcadic.connect(
      System.fetch_env!("ARCADEDB_URL"),
      System.fetch_env!("ARCADEDB_DATABASE"),
      auth: {System.fetch_env!("ARCADEDB_USERNAME"), System.fetch_env!("ARCADEDB_PASSWORD")}
    )
  end
end

defmodule MyApp.Document do
  use Ash.Resource, domain: MyApp.Graph, data_layer: AshArcadic.DataLayer

  arcade do
    client MyApp.GraphClient
    label :Document
  end

  attributes do
    uuid_primary_key :id
    attribute :title, :string, allow_nil?: false
  end

  actions do
    default_accept [:title]
    defaults [:create, :read]
  end
end

defmodule MyApp.Graph do
  use Ash.Domain

  resources do
    resource MyApp.Document
  end
end
Ash.create!(MyApp.Document, %{title: "Field notes"})
Ash.read!(MyApp.Document)

Tutorials

Topics

How-to

Reference

Compatibility

See Compatibility for supported toolchains, database versions, and dependency requirements.

License

MIT.