AshScylla.DataLayer.Dsl (AshScylla v0.1.1)

Copy Markdown View Source

DSL extensions for configuring ScyllaDB-specific options on Ash resources.

Usage

defmodule MyApp.MyResource do
  use Ash.Resource,
    data_layer: AshScylla.DataLayer

  ash_scylla do
    table "my_table"
    keyspace "my_keyspace"
    consistency :quorum
    ttl 3600

    # Define secondary indexes for non-primary key columns
    secondary_index :email
    secondary_index [:name, :age]
    secondary_index :status, name: "idx_user_status"
  end

  attributes do
    uuid_primary_key :id
    attribute :name, :string
    attribute :email, :string
    attribute :status, :string
    attribute :age, :integer
  end
end

Options

  • :table - The table name in ScyllaDB (overrides default)
  • :keyspace - The keyspace to use (overrides repo default)
  • :consistency - The consistency level for reads/writes
  • :ttl - Default TTL for inserted records (in seconds)
  • :secondary_index - Define secondary indexes for non-primary key columns
  • :materialized_view - Define materialized views with different primary key structure

Summary

Functions

Macro for configuring ScyllaDB options in Ash resources.

Gets the configured consistency level for a resource.

Checks if a column has a secondary index defined.

Gets the configured keyspace for a resource.

Gets the materialized views defined for a resource.

Gets the secondary indexes defined for a resource.

Gets the configured table name for a resource.

Gets the configured TTL for a resource.

Functions

ash_scylla(list)

(macro)

Macro for configuring ScyllaDB options in Ash resources.

Examples

ash_scylla do
  table "users"
  keyspace "my_keyspace"
  consistency :quorum
  ttl 3600

  # Define secondary indexes for non-primary key columns
  secondary_index :email
  secondary_index [:name, :age]

  # Define materialized views
  materialized_view :users_by_email,
    primary_key: [:email, :id],
    include_columns: [:name, :age]
end

consistency(resource)

Gets the configured consistency level for a resource.

has_secondary_index?(resource, column)

Checks if a column has a secondary index defined.

keyspace(resource)

Gets the configured keyspace for a resource.

materialized_views(resource)

Gets the materialized views defined for a resource.

Returns a list of maps with keys:

  • :name - the view name (atom)
  • :config - the view configuration keyword list

secondary_indexes(resource)

Gets the secondary indexes defined for a resource.

Returns a list of maps with keys:

  • :columns - list of column names (atoms)
  • :name - optional custom index name
  • :options - additional options

table(resource)

Gets the configured table name for a resource.

ttl(resource)

Gets the configured TTL for a resource.