AshArcadic
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.
- Use Ash actions for graph records, including bulk writes and upserts.
- Load related records through graph edges and run ranked searches through read actions.
- Scope graph operations by tenant and enforce storage rules for sensitive attributes.
- Mirror PostgreSQL changes with the optional CDC sink, which commits its checkpoint with the corresponding graph writes.
Installation
Add this dependency to your Ash application and run mix deps.get.
{:ash_arcadic, "~> 3.0"}
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
- Resources and connections
- Multitenancy and sensitive data
- Relationships and traversal
- Reads and expressions
- Writes and transactions
- Ranked search
- PostgreSQL change data capture
How-to
Reference
Compatibility
See Compatibility for supported toolchains, database versions, and dependency requirements.
License
MIT.