Authors: Ransom Richardson (ransom@ransomr.net).
An Erlang interface to Amazon's DynamoDB.
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/operationlist.html
erlcloud_ddb2 implements the entire 20120810 API.
Method names match DynamoDB operations converted to
lower_case_with_underscores. The one exception is query, which is
an Erlang reserved word. The q method implements Query.
Required parameters are passed as function arguments. In addition all methods take an options proplist argument which can be used to pass optional parameters. See function documentation for examples.
Table names, key names, attribute names and any other input strings except attribute values must be binary strings.
Attribute values may be either {Type, Value} or Value. If only
Value is provided then the type is inferred. Lists (iolists are
handled), binaries and atoms are assumed to be strings. The following are
equivalent: {s, <<"value">>}, <<"value">>, "value", value. Numbers
are assumed to be numbers. The following are equivalent: {n, 42},
42. To specify the AWS binary or set types an explicit Type
must be provided. For example: {b, <<1,2,3>>} or {ns,
[4,5,6]}. Note that binary values will be base64 encoded and
decoded automatically. Since some atoms (such as true, false, not_null,
null, undefined, delete, etc) have special meanings in some cases,
use them carefully.
Output is in the form of {ok, Value} or {error, Reason}. The
format of Value is controlled by the out option, which defaults
to simple. The possible values are:
* simple - The most interesting part of the output. For example
get_item will return the item.
* record - A record containing all the information from the
DynamoDB response except field types. This is useful if you need more detailed
information than what is returned with simple. For example, with
scan and query the record will contain the last evaluated key
which can be used to continue the operation.
* typed_record - A record containing all the information from the
DynamoDB response. All field values are returned with type information.
* json - The output from DynamoDB as processed by jsx:decode
but with no further manipulation. This would rarely be useful,
unless the DynamoDB API is updated to include data that is not yet
parsed correctly.
Items will be returned as a list of {Name, Value}. In most cases
the output will have type information removed. For example:
[{<<"String Attribute">>, <<"value">>}, {<<"Number Attribute">>,
42}, {<<"BinaryAttribute">>, <<1,2,3>>}]. The exception is for
output fields that are intended to be passed to a subsequent call,
such as unprocessed_keys and last_evaluated_key. Those will
contain typed attribute values so that they may be correctly passed
to subsequent calls.
DynamoDB errors are return in the form {error, {ErrorCode,
Message}} where ErrorCode and 'Message' are both binary
strings. List of error codes:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html. So
to handle conditional check failures, match {error,
{<<"ConditionalCheckFailedException">>, _}}.
erlcloud_ddb_util provides a higher level API that implements common
operations that may require multiple DynamoDB API calls.
attr_defs() = maybe_list({attr_name(), attr_type()})
attr_name() = binary()
attr_type() = s | n | b | bool | null | ss | ns | bs | l | m
attributes_to_get_opt() = {attributes_to_get, [attr_name()]}
batch_get_item_opt() = return_consumed_capacity_opt() | out_opt()
batch_get_item_opts() = [batch_get_item_opt()]
batch_get_item_request_item() = {table_name(), [key(), ...], batch_get_item_request_item_opts()} | {table_name(), [key(), ...]}
batch_get_item_request_item_opt() = expression_attribute_names_opt() | projection_expression_opt() | attributes_to_get_opt() | consistent_read_opt()
batch_get_item_request_item_opts() = [batch_get_item_request_item_opt()]
batch_get_item_request_items() = maybe_list(batch_get_item_request_item())
batch_get_item_return() = ddb_return(#ddb2_batch_get_item{}, [out_item()])
batch_write_item_delete() = {delete, key()}
batch_write_item_opt() = return_consumed_capacity_opt() | return_item_collection_metrics_opt() | out_opt()
batch_write_item_opts() = [batch_write_item_opt()]
batch_write_item_put() = {put, in_item()}
batch_write_item_request() = batch_write_item_put() | batch_write_item_delete()
batch_write_item_request_item() = {table_name(), [batch_write_item_request()]}
batch_write_item_request_items() = maybe_list(batch_write_item_request_item())
batch_write_item_return() = ddb_return(#ddb2_batch_write_item{}, #ddb2_batch_write_item{})
boolean_opt(Name) = Name | {Name, boolean()}
comparison_op() = eq | ne | le | lt | ge | gt | not_null | null | contains | not_contains | begins_with | in | between
condition() = {attr_name(), not_null | null} | {attr_name(), in_attr_value()} | {attr_name(), in_attr_value(), comparison_op()} | {attr_name(), {in_attr_value(), in_attr_value()}, between} | {attr_name(), [in_attr_value(), ...], in}
condition_expression_opt() = {condition_expression, expression()}
conditional_op() = '\'and\'' | '\'or\''
conditional_op_opt() = {conditional_op, conditional_op()}
conditions() = maybe_list(condition())
consistent_read_opt() = boolean_opt(consistent_read)
create_table_opt() = {local_secondary_indexes, local_secondary_indexes()} | {global_secondary_indexes, global_secondary_indexes()} | {stream_specification, stream_specification()}
create_table_opts() = [create_table_opt()]
create_table_return() = ddb_return(#ddb2_create_table{}, #ddb2_table_description{})
ddb_opts() = [out_opt()]
ddb_return(Record, Simple) = {ok, jsx:json_term() | Record | Simple} | {error, term()}
delete_item_opt() = expression_attribute_names_opt() | expression_attribute_values_opt() | condition_expression_opt() | conditional_op_opt() | expected_opt() | {return_values, none | all_old} | return_consumed_capacity_opt() | return_item_collection_metrics_opt() | out_opt()
delete_item_opts() = [delete_item_opt()]
delete_item_return() = ddb_return(#ddb2_delete_item{}, out_item())
delete_table_return() = ddb_return(#ddb2_delete_table{}, #ddb2_table_description{})
describe_limits_return() = ddb_return(#ddb2_describe_limits{}, #ddb2_describe_limits{})
describe_table_return() = ddb_return(#ddb2_describe_table{}, #ddb2_table_description{})
describe_time_to_live_return() = ddb_return(#ddb2_describe_time_to_live{}, #ddb2_time_to_live_description{})
expected_opt() = {expected, in_expected()}
expression() = binary()
expression_attribute_names() = [{binary(), attr_name()}]
expression_attribute_names_opt() = {expression_attribute_names, expression_attribute_names()}
expression_attribute_values() = [{binary(), in_attr_value()}]
expression_attribute_values_opt() = {expression_attribute_values, expression_attribute_values()}
get_item_opt() = expression_attribute_names_opt() | projection_expression_opt() | attributes_to_get_opt() | consistent_read_opt() | return_consumed_capacity_opt() | out_opt()
get_item_opts() = [get_item_opt()]
get_item_return() = ddb_return(#ddb2_get_item{}, out_item())
global_secondary_index_def() = {index_name(), key_schema(), projection(), read_units(), write_units()}
global_secondary_index_update() = {index_name(), read_units(), write_units()} | {index_name(), delete} | global_secondary_index_def()
global_secondary_index_updates() = maybe_list(global_secondary_index_update())
global_secondary_indexes() = maybe_list(global_secondary_index_def())
hash_key_name() = attr_name()
in_attr() = {attr_name(), in_attr_value()}
in_attr_value() = in_string_value() | in_number_value() | {s, in_string_value()} | {n, in_number_value()} | {b, in_binary_value()} | {bool, boolean()} | {null, true} | {ss, [in_string_value(), ...]} | {ns, [in_number_value(), ...]} | {bs, [in_binary_value(), ...]} | {l, [in_attr_value()]} | {m, [in_attr()]}
in_binary_value() = binary() | [byte()]
non-empty
in_expected() = maybe_list(in_expected_item())
in_expected_item() = {attr_name(), false} | {attr_name(), true, in_attr_value()} | condition()
in_item() = [in_attr()]
in_number_value() = number()
in_string_value() = binary() | iolist() | atom()
non-empty
in_update() = {attr_name(), in_attr_value(), update_action()} | in_attr() | {attr_name(), delete}
in_updates() = maybe_list(in_update())
index_name() = binary()
key() = maybe_list(in_attr())
key_schema() = hash_key_name() | {hash_key_name(), range_key_name()}
list_tables_opt() = {limit, pos_integer()} | {exclusive_start_table_name, table_name() | undefined} | out_opt()
list_tables_opts() = [list_tables_opt()]
list_tables_return() = ddb_return(#ddb2_list_tables{}, [table_name()])
local_secondary_index_def() = {index_name(), range_key_name(), projection()}
local_secondary_indexes() = maybe_list(local_secondary_index_def())
maybe_list(T) = T | [T]
ok_return(T) = {ok, T} | {error, term()}
out_attr() = {attr_name(), out_attr_value()}
out_attr_value() = binary() | number() | boolean() | undefined | [binary()] | [number()] | [out_attr_value()] | [out_attr()]
out_item() = [out_attr() | in_attr()]
in_attr in the case of typed_record
out_opt() = {out, out_type()}
out_type() = json | record | typed_record | simple
projection() = keys_only | {include, [attr_name()]} | all
projection_expression_opt() = {projection_expression, expression()}
put_item_opt() = expression_attribute_names_opt() | expression_attribute_values_opt() | condition_expression_opt() | conditional_op_opt() | expected_opt() | {return_values, none | all_old} | return_consumed_capacity_opt() | return_item_collection_metrics_opt() | out_opt()
put_item_opts() = [put_item_opt()]
put_item_return() = ddb_return(#ddb2_put_item{}, out_item())
q_opt() = expression_attribute_names_opt() | expression_attribute_values_opt() | projection_expression_opt() | attributes_to_get_opt() | consistent_read_opt() | {filter_expression, expression()} | conditional_op_opt() | {query_filter, conditions()} | {limit, pos_integer()} | {exclusive_start_key, key() | undefined} | boolean_opt(scan_index_forward) | {index_name, index_name()} | {select, select()} | return_consumed_capacity_opt() | out_opt()
q_opts() = [q_opt()]
q_return() = ddb_return(#ddb2_q{}, [out_item()])
range_key_name() = attr_name()
read_units() = pos_integer()
return_consumed_capacity() = none | total | indexes
return_consumed_capacity_opt() = {return_consumed_capacity, return_consumed_capacity()}
return_item_collection_metrics() = none | size
return_item_collection_metrics_opt() = {return_item_collection_metrics, return_item_collection_metrics()}
return_value() = none | all_old | updated_old | all_new | updated_new
scan_opt() = expression_attribute_names_opt() | expression_attribute_values_opt() | projection_expression_opt() | attributes_to_get_opt() | consistent_read_opt() | {filter_expression, expression()} | conditional_op_opt() | {scan_filter, conditions()} | {limit, pos_integer()} | {exclusive_start_key, key() | undefined} | {segment, non_neg_integer()} | {total_segments, pos_integer()} | {index_name, index_name()} | {select, select()} | return_consumed_capacity_opt() | out_opt()
scan_opts() = [scan_opt()]
scan_return() = ddb_return(#ddb2_scan{}, [out_item()])
select() = all_attributes | all_projected_attributes | count | specific_attributes
stream_specification() = false | {true, stream_view_type()}
stream_view_type() = keys_only | new_image | old_image | new_and_old_images
table_name() = binary()
time_to_live_status() = enabled | disabled | enabling | disabling
update_action() = put | add | delete
update_item_opt() = expression_attribute_names_opt() | expression_attribute_values_opt() | condition_expression_opt() | conditional_op_opt() | expected_opt() | {return_values, return_value()} | return_consumed_capacity_opt() | return_item_collection_metrics_opt() | out_opt()
update_item_opts() = [update_item_opt()]
update_item_return() = ddb_return(#ddb2_update_item{}, out_item())
update_table_opt() = {provisioned_throughput, {read_units(), write_units()}} | {attribute_definitions, attr_defs()} | {global_secondary_index_updates, global_secondary_index_updates()} | {stream_specification, stream_specification()} | out_opt()
update_table_opts() = [update_table_opt()]
update_table_return() = ddb_return(#ddb2_update_table{}, #ddb2_table_description{})
update_time_to_live_opt() = {attribute_name, attr_name()} | {enabled, boolean()}
update_time_to_live_opts() = [update_time_to_live_opt()]
update_time_to_live_return() = ddb_return(#ddb2_update_time_to_live{}, #ddb2_time_to_live_specification{})
write_units() = pos_integer()
batch_get_item(RequestItems::batch_get_item_request_items()) -> batch_get_item_return()
batch_get_item(RequestItems::batch_get_item_request_items(), Opts::batch_get_item_opts()) -> batch_get_item_return()
batch_get_item(RequestItems::batch_get_item_request_items(), Opts::batch_get_item_opts(), Config::aws_config()) -> batch_get_item_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html
Get 4 items total from 2 tables.
{ok, Record} =
erlcloud_ddb2:batch_get_item(
[{<<"Forum">>,
[{<<"Name">>, {s, <<"Amazon DynamoDB">>}},
{<<"Name">>, {s, <<"Amazon RDS">>}},
{<<"Name">>, {s, <<"Amazon Redshift">>}}],
[{projection_expression, <<"Name, Threads, Messages, Views">>}]},
{<<"Thread">>,
[[{<<"ForumName">>, {s, <<"Amazon DynamoDB">>}},
{<<"Subject">>, {s, <<"Concurrent reads">>}}]],
[{projection_expression, <<"Tags, Message">>}]}],
[{return_consumed_capacity, total},
{out, record}]),
batch_write_item(RequestItems::batch_write_item_request_items()) -> batch_write_item_return()
batch_write_item(RequestItems::batch_write_item_request_items(), Opts::batch_write_item_opts()) -> batch_write_item_return()
batch_write_item(RequestItems::batch_write_item_request_items(), Opts::batch_write_item_opts(), Config::aws_config()) -> batch_write_item_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html
Put 4 items in the "Forum" table.
{ok, Record} =
erlcloud_ddb2:batch_write_item(
[{<<"Forum">>,
[{put, [{<<"Name">>, {s, <<"Amazon DynamoDB">>}},
{<<"Category">>, {s, <<"Amazon Web Services">>}}]},
{put, [{<<"Name">>, {s, <<"Amazon RDS">>}},
{<<"Category">>, {s, <<"Amazon Web Services">>}}]},
{put, [{<<"Name">>, {s, <<"Amazon Redshift">>}},
{<<"Category">>, {s, <<"Amazon Web Services">>}}]},
{put, [{<<"Name">>, {s, <<"Amazon ElastiCache">>}},
{<<"Category">>, {s, <<"Amazon Web Services">>}}]}
]}],
[{return_consumed_capacity, total},
{out, record}]),
configure(AccessKeyID::string(), SecretAccessKey::string()) -> ok
configure(AccessKeyID::string(), SecretAccessKey::string(), Host::string()) -> ok
configure(AccessKeyID::string(), SecretAccessKey::string(), Host::string(), Port::non_neg_integer()) -> ok
configure(AccessKeyID::string(), SecretAccessKey::string(), Host::string(), Port::non_neg_integer(), Scheme::string()) -> ok
create_table(Table::table_name(), AttrDefs::attr_defs(), KeySchema::key_schema(), ReadUnits::read_units(), WriteUnits::write_units()) -> create_table_return()
create_table(Table::table_name(), AttrDefs::attr_defs(), KeySchema::key_schema(), ReadUnits::read_units(), WriteUnits::write_units(), Opts::create_table_opts()) -> create_table_return()
create_table(Table::table_name(), AttrDefs::attr_defs(), KeySchema::key_schema(), ReadUnits::read_units(), WriteUnits::write_units(), Opts::create_table_opts(), Config::aws_config()) -> create_table_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html
Create a table with hash key "ForumName" and range key "Subject" with a local secondary index on "LastPostDateTime" and a global secondary index on "Subject" as hash key and "LastPostDateTime" as range key, read and write capacity 10, projecting all fields
{ok, Description} =
erlcloud_ddb2:create_table(
<<"Thread">>,
[{<<"ForumName">>, s},
{<<"Subject">>, s},
{<<"LastPostDateTime">>, s}],
{<<"ForumName">>, <<"Subject">>},
5,
5,
[{local_secondary_indexes,
[{<<"LastPostIndex">>, <<"LastPostDateTime">>, keys_only}]},
{global_secondary_indexes, [
{<<"SubjectTimeIndex">>, {<<"Subject">>, <<"LastPostDateTime">>}, all, 10, 10}
]}
]),
delete_item(Table::table_name(), Key::key()) -> delete_item_return()
delete_item(Table::table_name(), Key::key(), Opts::delete_item_opts()) -> delete_item_return()
delete_item(Table::table_name(), Key::key(), Opts::delete_item_opts(), Config::aws_config()) -> delete_item_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html
Delete an item from the "Thread" table if it doesn't have a "Replies" attribute.
{ok, Item} =
erlcloud_ddb2:delete_item(
<<"Thread">>,
[{<<"ForumName">>, {s, <<"Amazon DynamoDB">>}},
{<<"Subject">>, {s, <<"How do I update multiple items?">>}}],
[{return_values, all_old},
{condition_expression, <<"attribute_not_exists(Replies)">>}]),
The ConditionExpression option can also be used in place of the legacy ConditionalOperator or Expected parameters.
{ok, Item} =
erlcloud_ddb2:delete_item(
<<"Thread">>,
[{<<"ForumName">>, {s, <<"Amazon DynamoDB">>}},
{<<"Subject">>, {s, <<"How do I update multiple items?">>}}],
[{return_values, all_old},
{condition_expression, <<"attribute_not_exists(#replies)">>},
{expression_attribute_names, [{<<"#replies">>, <<"Replies">>}]}]),
delete_table(Table::table_name()) -> delete_table_return()
delete_table(Table::table_name(), Opts::ddb_opts()) -> delete_table_return()
delete_table(Table::table_name(), Opts::ddb_opts(), Config::aws_config()) -> delete_table_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteTable.html
Delete "Reply" table.
{ok, Description} =
erlcloud_ddb2:delete_table(<<"Reply">>),
describe_limits() -> describe_limits_return()
describe_limits(Opts::ddb_opts()) -> describe_limits_return()
describe_limits(Opts::ddb_opts(), Config::aws_config()) -> describe_limits_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeLimits.html
Describe the current provisioned-capacity limits for your AWS account.
{ok, Limits} =
erlcloud_ddb2:describe_limits(),
describe_table(Table::table_name()) -> describe_table_return()
describe_table(Table::table_name(), Opts::ddb_opts()) -> describe_table_return()
describe_table(Table::table_name(), Opts::ddb_opts(), Config::aws_config()) -> describe_table_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html
Describe "Thread" table.
{ok, Description} =
erlcloud_ddb2:describe_table(<<"Thread">>),
describe_time_to_live(Table::table_name()) -> describe_time_to_live_return()
describe_time_to_live(Table::table_name(), DbOpts::ddb_opts()) -> describe_time_to_live_return()
describe_time_to_live(Table::table_name(), DbOpts::ddb_opts(), Config::aws_config()) -> describe_time_to_live_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTimeToLive.html
{ok, Description} = erlcloud_ddb2:describe_time_to_live(<<"SessionData">>),
get_item(Table::table_name(), Key::key()) -> get_item_return()
get_item(Table::table_name(), Key::key(), Opts::get_item_opts()) -> get_item_return()
get_item(Table::table_name(), Key::key(), Opts::get_item_opts(), Config::aws_config()) -> get_item_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html
Get selected attributes from an item in the "Thread" table.
{ok, Item} =
erlcloud_ddb2:get_item(
<<"Thread">>,
[{<<"ForumName">>, {s, <<"Amazon DynamoDB">>}},
{<<"Subject">>, {s, <<"How do I update multiple items?">>}}],
[{projection_expression, <<"LastPostDateTime, Message, Tags">>},
consistent_read,
{return_consumed_capacity, total}]),
list_tables() -> list_tables_return()
list_tables(Opts::list_tables_opts()) -> list_tables_return()
list_tables(Opts::list_tables_opts(), Config::aws_config()) -> list_tables_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html
Get the next 3 table names after "Forum".
{ok, Tables} =
erlcloud_ddb2:list_tables(
[{limit, 3},
{exclusive_start_table_name, <<"Forum">>}]),
new(AccessKeyID::string(), SecretAccessKey::string()) -> aws_config()
new(AccessKeyID::string(), SecretAccessKey::string(), Host::string()) -> aws_config()
new(AccessKeyID::string(), SecretAccessKey::string(), Host::string(), Port::non_neg_integer()) -> aws_config()
new(AccessKeyID::string(), SecretAccessKey::string(), Host::string(), Port::non_neg_integer(), Scheme::string()) -> aws_config()
put_item(Table::table_name(), Item::in_item()) -> put_item_return()
put_item(Table::table_name(), Item::in_item(), Opts::put_item_opts()) -> put_item_return()
put_item(Table::table_name(), Item::in_item(), Opts::put_item_opts(), Config::aws_config()) -> put_item_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
Put an item in the "Thread" table if it does not already exist.
{ok, []} =
erlcloud_ddb2:put_item(
<<"Thread">>,
[{<<"LastPostedBy">>, <<"fred@example.com">>},
{<<"ForumName">>, <<"Amazon DynamoDB">>},
{<<"LastPostDateTime">>, <<"201303190422">>},
{<<"Tags">>, {ss, [<<"Update">>, <<"Multiple Items">>, <<"HelpMe">>]}},
{<<"Subject">>, <<"How do I update multiple items?">>},
{<<"Message">>,
<<"I want to update multiple items in a single API call. What is the best way to do that?">>}],
[{condition_expression, <<"ForumName <> :f and Subject <> :s">>},
{expression_attribute_values,
[{<<":f">>, <<"Amazon DynamoDB">>},
{<<":s">>, <<"How do I update multiple items?">>}]}]),
The ConditionExpression option can be used in place of the legacy Expected parameter.
{ok, []} =
erlcloud_ddb2:put_item(
<<"Thread">>,
[{<<"LastPostedBy">>, <<"fred@example.com">>},
{<<"ForumName">>, <<"Amazon DynamoDB">>},
{<<"LastPostDateTime">>, <<"201303190422">>},
{<<"Tags">>, {ss, [<<"Update">>, <<"Multiple Items">>, <<"HelpMe">>]}},
{<<"Subject">>, <<"How do I update multiple items?">>},
{<<"Message">>,
<<"I want to update multiple items in a single API call. What is the best way to do that?">>}],
[{condition_expression, <<"#forum <> :forum AND attribute_not_exists(#subject)">>},
{expression_attribute_names, [{<<"#forum">>, <<"ForumName">>}, {<<"#subject">>, <<"Subject">>}]},
{expression_attribute_values, [{<<":forum">>, <<"Amazon DynamoDB">>}]}]),
q(Table::table_name(), KeyConditionsOrExpression::conditions() | expression()) -> q_return()
q(Table::table_name(), KeyConditionsOrExpression::conditions() | expression(), Opts::q_opts()) -> q_return()
q(Table::table_name(), KeyConditionsOrExpression::conditions() | expression(), Opts::q_opts(), Config::aws_config()) -> q_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html
KeyConditions are treated as a required parameter, which appears to be the case despite what the documentation says.
Get up to 3 itesm from the "Thread" table with "ForumName" of "Amazon DynamoDB" and "LastPostDateTime" between specified value. Use the "LastPostIndex".
{ok, Items} =
erlcloud_ddb2:q(
<<"Thread">>,
<<"ForumName = :n AND LastPostDateTime BETWEEN :t1 AND :t2">>,
[{expression_attribute_values,
[{<<":n">>, <<"Amazon DynamoDB">>},
{<<":t1">>, <<"20130101">>},
{<<":t2">>, <<"20130115">>}]},
{index_name, <<"LastPostIndex">>},
{select, all_attributes},
{limit, 3},
{consistent_read, true},
{filter_expression, <<"#user = :user">>},
{expression_attribute_names, [{<<"#user">>, <<"User">>}]},
{expression_attribute_values, [{<<":user">>, <<"User A">>}]}]),
scan(Table::table_name()) -> scan_return()
scan(Table::table_name(), Opts::scan_opts()) -> scan_return()
scan(Table::table_name(), Opts::scan_opts(), Config::aws_config()) -> scan_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html
Return all items in the "Reply" table.
{ok, Record} =
erlcloud_ddb2:scan(
<<"Reply">>,
[{return_consumed_capacity, total},
{out, record}]),
update_item(Table::table_name(), Key::key(), UpdatesOrExpression::in_updates() | expression()) -> update_item_return()
update_item(Table::table_name(), Key::key(), UpdatesOrExpression::in_updates() | expression(), Opts::update_item_opts()) -> update_item_return()
update_item(Table::table_name(), Key::key(), UpdatesOrExpression::in_updates() | expression(), Opts::update_item_opts(), Config::aws_config()) -> update_item_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html
AttributeUpdates is treated as a required parameter because callers will almost always provide it. If no updates are desired, You can pass [] for that argument.
Update specific item in the "Thread" table by setting "LastPostBy" if it has the expected previous value.
{ok, Item} =
erlcloud_ddb2:update_item(
<<"Thread">>,
[{<<"ForumName">>, {s, <<"Amazon DynamoDB">>}},
{<<"Subject">>, {s, <<"How do I update multiple items?">>}}],
<<"set LastPostedBy = :val1">>,
[{condition_expression, <<"LastPostedBy = :val2">>},
{expression_attribute_values,
[{<<":val1">>, <<"alice@example.com">>},
{<<":val2">>, <<"fred@example.com">>}]},
{return_values, all_new}]),
update_table(Table::table_name(), Opts::update_table_opts()) -> update_table_return()
update_table(Table::table_name(), Opts::update_table_opts(), Config::aws_config()) -> update_table_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTable.html
<<"SubjectIdx">> to have 10 units of read write capacity
erlcloud_ddb2:update_table(
<<"Thread">>,
[{provisioned_throughput, {10, 10}},
{global_secondary_index_updates, [{<<"SubjectIdx">>, 10, 10}]}])
update_table(Table::table_name(), ReadUnits::read_units(), WriteUnits::write_units(), Opts::update_table_opts()) -> update_table_return()
update_table(Table::table_name(), ReadUnits::non_neg_integer(), WriteUnits::non_neg_integer(), Opts::update_table_opts(), Config::aws_config()) -> update_table_return()
update_time_to_live(Table::table_name(), Opts::update_time_to_live_opts()) -> update_time_to_live_return()
update_time_to_live(Table::table_name(), Opts::update_time_to_live_opts(), Config::aws_config()) -> update_time_to_live_return()
DynamoDB API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTimeToLive.html
erlcloud_ddb2:update_time_to_live(
<<"SessionData">>,
[{attribute_name, <<"ExpirationTime">>},
{enabled, true}])
update_time_to_live(Table::table_name(), AttributeName::attr_name(), Enabled::boolean(), Config::aws_config()) -> update_time_to_live_return()
Generated by EDoc