Amazon DynamoDB Streams events.
stream = Mayfly.Events.DynamoDB.decode(event)
for %{event_name: :insert, new_image: item} <- stream.records do
# item is a plain map: %{"id" => "a1", "price" => 12.5, "tags" => ["x"], ...}
endDynamoDB's typed attribute values are converted to Elixir terms:
| Type | Elixir |
|---|---|
S | binary |
N | integer or float |
BOOL | boolean |
NULL | nil |
B | binary (base64-decoded) |
L | list |
M | map |
SS / NS / BS | list of binaries / numbers / binaries |
from_attribute_values/1 is public so it can be reused for other
DynamoDB JSON (e.g. GetItem responses).
Summary
Functions
Partial batch response for the given sequence numbers.
Decodes a DynamoDB Streams event.
Converts a map of DynamoDB attribute values (%{"id" => %{"S" => "a"}}) into plain terms.
Converts one attribute value.
Runs fun per record, collecting failures by sequence number.
Types
@type t() :: %Mayfly.Events.DynamoDB{ raw: map(), records: [Mayfly.Events.DynamoDB.Record.t()] }
Functions
Partial batch response for the given sequence numbers.
Decodes a DynamoDB Streams event.
Converts a map of DynamoDB attribute values (%{"id" => %{"S" => "a"}}) into plain terms.
Converts one attribute value.
@spec process_batch(t(), (Mayfly.Events.DynamoDB.Record.t() -> term())) :: %{ batchItemFailures: [%{itemIdentifier: String.t()}] }
Runs fun per record, collecting failures by sequence number.