AshScylla.DataLayer.SecondaryIndex (AshScylla v1.0.2)

Copy Markdown View Source

Struct representing a secondary index definition on a ScyllaDB table.

Used by the DSL, migration generator, and filter validator to introspect index configurations programmatically.

Fields

  • :columns — List of column names (atoms) to index
  • :name — Optional custom index name override
  • :options — Additional index options

Summary

Types

t()

A secondary index definition on a ScyllaDB table.

Functions

Generates the default index name for a given table and column.

Returns the effective index name — custom name if set, otherwise the default.

Parses a secondary index DSL input into a %SecondaryIndex{} struct.

Types

t()

@type t() :: %AshScylla.DataLayer.SecondaryIndex{
  columns: [atom()],
  name: String.t() | nil,
  options: keyword()
}

A secondary index definition on a ScyllaDB table.

Used by the DSL, migration generator, and filter validator to introspect index configurations programmatically.

Functions

default_name(table, column)

@spec default_name(String.t(), atom()) :: String.t()

Generates the default index name for a given table and column.

Examples

iex> AshScylla.DataLayer.SecondaryIndex.default_name("users", :email)
"idx_users_email"

effective_name(secondary_index, table, column)

@spec effective_name(t(), String.t(), atom()) :: String.t()

Returns the effective index name — custom name if set, otherwise the default.

parse(column)

@spec parse(atom() | [atom()] | {atom(), keyword()}) :: t()

Parses a secondary index DSL input into a %SecondaryIndex{} struct.

Accepts three call signatures:

  • A single atom: :email
  • A list of atoms: [:name, :age]
  • A tuple with options: {:email, name: "idx_email"}

Examples

iex> AshScylla.DataLayer.SecondaryIndex.parse(:email)
%AshScylla.DataLayer.SecondaryIndex{columns: [:email], name: nil, options: []}

iex> AshScylla.DataLayer.SecondaryIndex.parse([:name, :age])
%AshScylla.DataLayer.SecondaryIndex{columns: [:name, :age], name: nil, options: []}

iex> AshScylla.DataLayer.SecondaryIndex.parse({:email, name: "idx_email"})
%AshScylla.DataLayer.SecondaryIndex{columns: [:email], name: "idx_email", options: [name: "idx_email"]}