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

Add this dependency to your Ash application and run mix deps.get.

{:ash_arcadic, "~> 3.2"}

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.