Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2 from martinrehfeld/batch_get

Add wrapper for the BatchGetItem API
  • Loading branch information...
commit 4fbf474061414ab290fdd3acf24e54a7d6670131 2 parents 06b7191 + 4f1d400
@dialtone dialtone authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/dinerl.erl
View
19 src/dinerl.erl
@@ -11,6 +11,7 @@
-export([describe_table/1, describe_table/2, update_table/3, update_table/4]).
-export([list_tables/0, list_tables/1, list_tables/2, put_item/3, put_item/4]).
-export([delete_item/3, delete_item/4, get_item/3, get_item/4]).
+-export([get_items/1, get_items/2, get_items/3, get_items/4]).
-export([update_item/3, update_item/4]).
-export([update_data/3]).
@@ -144,6 +145,24 @@ get_item(T, K, [{attrs, V}|Rest], Acc, Timeout) ->
+get_items(Table, Keys, Options) ->
+ do_get_items([{Table, Keys, Options}], [], undefined).
+get_items(Table, Keys, Options, Timeout) ->
+ do_get_items([{Table, Keys, Options}], [], Timeout).
+get_items(MultiTableQuery) ->
+ do_get_items(MultiTableQuery, [], undefined).
+get_items(MultiTableQuery, Timeout) ->
+ do_get_items(MultiTableQuery, [], Timeout).
+
+do_get_items([], Acc, Timeout) ->
+ api(batch_get_item, [{<<"RequestItems">>, Acc}], Timeout);
+do_get_items([{Table, Keys, Options}|Rest], Acc, Timeout) ->
+ Attrs = proplists:get_value(attrs, Options, []),
+ do_get_items(Rest, [{Table, [{<<"Keys">>, Keys}, {<<"AttributesToGet">>, Attrs}]}|Acc], Timeout).
+
+
+
+
update_item(Table, Key, Options) ->
update_item(Table, Key, Options, undefined).
update_item(Table, Key, Options, Timeout) ->
Please sign in to comment.
Something went wrong with that request. Please try again.