# `AshScylla.DataLayer.SecondaryIndex`
[🔗](https://github.com/ohhi-vn/ash_scylla/blob/main/lib/ash_scylla/data_layer/secondary_index.ex#L15)

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

# `t`

```elixir
@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.

# `default_name`

```elixir
@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`

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

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

# `parse`

```elixir
@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"]}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
