View Source Dynamo.Request (Dynamo v0.2.0)
Pure builders for DynamoDB request payloads.
Every function returns {:ok, {action, payload}} or {:error, %Dynamo.Error{}}
and performs no I/O. Dynamo.Repo executes them through Dynamo.Client.
Because they are pure they can be unit-tested against the exact JSON DynamoDB
expects.
Common options
Most builders accept these expression options:
:condition–ConditionExpressionstring:filter–FilterExpressionstring (query/scan):projection–ProjectionExpressionstring or list of field atoms:names– map of"#placeholder" => "attribute"(ExpressionAttributeNames):values– map of":placeholder" => value. Values that are not already DynamoDB attribute values (Dynamo.Raw) are dumped with:any.:return_values–:none | :all_old | :all_new | :updated_old | :updated_new:return_consumed_capacity–:none | :total | :indexes
Summary
Functions
BatchGetItem for up to 100 structs (same schema).
BatchWriteItem for up to 25 structs (mixed schemas/tables allowed).
{:delete, struct} tuples delete instead of put.
DeleteItem.
GetItem for a schema struct with populated key fields.
PutItem for a schema struct.
Query. The partition key is taken from the struct (table or :index). The
sort key condition comes from :sort_key
Scan a schema's table (or :index). Supports :segment/:total_segments.
SearchVectors on a schema's vector index.
TransactWriteItems. Each operation is one of
UpdateItem. changes is a keyword/map of field => change (see
Dynamo.Update), or pass update_expression: with names:/values: for a
raw expression.
Types
@type action() :: String.t()
@type payload() :: map()
@type result() :: {:ok, {action(), payload()}} | {:error, Dynamo.Error.t()}
Functions
BatchGetItem for up to 100 structs (same schema).
BatchWriteItem for up to 25 structs (mixed schemas/tables allowed).
{:delete, struct} tuples delete instead of put.
DeleteItem.
GetItem for a schema struct with populated key fields.
PutItem for a schema struct.
Query. The partition key is taken from the struct (table or :index). The
sort key condition comes from :sort_key:
- omitted – if the struct has sort-key fields populated:
begins_withon the generated (possibly partial) composite sort key for table queries, or equality for index /raw_keysqueries (single typed attribute); otherwise partition only {:eq, v},{:lt, v},{:lte, v},{:gt, v},{:gte, v},{:begins_with, v},{:between, lo, hi}– explicit condition;vis the raw sort key value (string for composite keys, typed value for GSI/raw keys):none– partition key only, ignore struct sort-key fields
Other options: :filter, :projection, :names, :values, :limit,
:start_key, :consistent (not allowed with :index), :descending,
:select (:count, :all_attributes, :all_projected_attributes).
Scan a schema's table (or :index). Supports :segment/:total_segments.
SearchVectors on a schema's vector index.
vector– list of floats; its length must match the index dimensions:top_k– 1..100 (default 10):filter–SearchConditionExpression; string orDynamo.ConditionDSL. When the index has apartition_key, the filter MUST include[partition_field: value](DynamoDB requires it).:projection– attributes to return (only projected ones are available); the vector itself is not returned unless you ask for it here:return_consumed_capacity–:total | :indexes | :none
TransactWriteItems. Each operation is one of:
{:put, struct, opts}–opts::condition,:names,:values{:update, struct, changes, opts}{:delete, struct, opts}{:check, struct, condition, opts}–ConditionCheck
(opts may be omitted.) Top-level opts: :client_request_token for
idempotency, :return_consumed_capacity.
UpdateItem. changes is a keyword/map of field => change (see
Dynamo.Update), or pass update_expression: with names:/values: for a
raw expression.