AshDynamo.DataLayer

Copy Markdown View Source

A DynamoDB data layer for Ash, backed by ExAws.Dynamo.

DSL Documentation

dynamodb

Configure the DynamoDB table backing this resource for querying.

Examples:

dynamodb do
  table "users"
  partition_key :email
  sort_key :inserted_at

  global_secondary_index :by_status do
    partition_key :status
    sort_key :inserted_at
  end
end

Options

NameTypeDefaultDocs
tableString.tTable name to read from/write to. Defaults to the underscored resource name.
partition_keyatomRequired partition (hash) key attribute name.
sort_keyatomnilOptional sort (range) key attribute name.

dynamodb.global_secondary_index

Defines a Global Secondary Index (GSI) for automatic query routing.

When a query filters on a GSI's partition key, AshDynamo automatically routes the query to that index instead of scanning the table.

global_secondary_index :by_status do
  partition_key :status
  sort_key :inserted_at
end

Options

NameTypeDefaultDocs
nameatomIndex name (used as the DynamoDB IndexName parameter).
partition_keyatomPartition (hash) key attribute for this GSI.
sort_keyatomnilOptional sort (range) key attribute for this GSI.