Module: Dynamodb::TableActions
Instance Method Summary collapse
- #_query(opts) ⇒ Object
- #create_table(_table_name, options) ⇒ Object
- #delete_item(_table_name, _key, options = {}) ⇒ Object
- #delete_table(_table_name) ⇒ Object
- #describe_table(_table_name) ⇒ Object
- #get_item(_table_name, _key, options = {}) ⇒ Object
- #list_tables ⇒ Object
- #put_item(_table_name, _item, options = {}) ⇒ Object
Instance Method Details
#_query(opts) ⇒ Object
34 35 36 37 38 |
# File 'lib/dynamodb/table_actions.rb', line 34 def _query(opts) result = client.query(opts) result.items = result.items.map { |x| item_to_object(x) } result end |
#create_table(_table_name, options) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dynamodb/table_actions.rb', line 52 def create_table(_table_name, ) resource.create_table( { table_name: _table_name, provisioned_throughput: { read_capacity_units: 5, write_capacity_units: 5, } }.merge!() ) end |
#delete_item(_table_name, _key, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/dynamodb/table_actions.rb', line 25 def delete_item(_table_name, _key, = {}) client.delete_item( { table_name: _table_name, key: _key }.merge!() ) end |
#delete_table(_table_name) ⇒ Object
48 49 50 |
# File 'lib/dynamodb/table_actions.rb', line 48 def delete_table(_table_name) client.delete_table(table_name: _table_name) end |
#describe_table(_table_name) ⇒ Object
40 41 42 |
# File 'lib/dynamodb/table_actions.rb', line 40 def describe_table(_table_name) client.describe_table(table_name: _table_name) end |
#get_item(_table_name, _key, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dynamodb/table_actions.rb', line 5 def get_item(_table_name, _key, = {}) _item = client.get_item( { table_name: _table_name, key: _key }.merge!() )[:item] _item ? item_to_object(_item) : nil end |
#list_tables ⇒ Object
44 45 46 |
# File 'lib/dynamodb/table_actions.rb', line 44 def list_tables client.list_tables.table_names end |
#put_item(_table_name, _item, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/dynamodb/table_actions.rb', line 16 def put_item(_table_name, _item, = {}) client.put_item( { table_name: _table_name, item: _item }.merge!() ) end |