class AWS::DynamoDB
item.delete
# delete an item and all of its attributes
#=> {“id”=>#<BigDecimal:10155f5d0,‘0.12345E5’,9(18)>, “tags”=>#<Set: {“item”, “sample”}>}
item.attributes.to_h
# get attributes
item.attributes.delete ‘colors’, ‘category’
# delete attributes
end
u.delete ‘foo’
u.set ‘category’ => ‘demo-category’
u.add ‘colors’ => %w(red)
item.attributes.update do |u|
# update an item with mixed add, delete, update
item.attributes.add ‘category’ => %w(demo), ‘tags’ => %w(sample item)
# add attributes to an item
item = table.items.create(‘id’ => 12345, ‘foo’ => ‘bar’)
# add an item
table.hash_key = [:id, :number]
table = dynamo_db.tables[‘another-table’]
# get an existing table by name and specify its hash key
table.status #=> :active
sleep 1 while table.status == :creating
table = dynamo_db.tables.create(‘my-table’, 10, 5)
dynamo_db = AWS::DynamoDB.new
# default schema (id string hash key)
# create a table (10 read and 5 write capacity units) with the
= Examples
see {AttributeCollection}.
and managing items. For more information on managing attributes,
See {Item} and {ItemCollection} for more information on creating
)
:numbers => [12, 24]
:colors => [“red”, “blue”],
item.attributes.set(
item.hash_value # => “abc123”
item = table.items.put(:id => “abc123”)
the table’s schema includes a range key – its range key value.
The identity of an item consists of its hash key value and – if
number set value.
attribute has a string name and a string, number, string set or
An item is a collection of one or more attributes, where each
= Items and Attributes
and managing tables.
See {Table} and {TableCollection} for more information on creating
sleep 1 while table.status == :creating
)
:hash_key => { :id => :string }
“MyTable”,
table = dynamo_db.tables.create(
designate a table name with a primary key.
step in writing data to DynamoDB is to create a table and
item in the table to have a unique primary key value. The first
primary key when you create a table, and the table requires each
scheme. You designate the attribute name (or names) to use for the
areas. All items in the table have the same primary key
Tables contain items, and organize information into discrete
= Tables
These will be cached in the process and re-used.
a request is made to Amazon STS for temproary session credentials.
@note If you make a request using AWS::DynamoDB with long-term credentials
credentials (e.g. requires a session token).
Amazon DynamoDB requires that all requests are made with short-term
= Credentials
:session_token => ‘…’)
:secret_access_key => ‘…’,
:access_key_id => ‘…’,
dynamo_db = AWS::DynamoDB.new(
Provides a high-level interface for using DynamoDB.
def batch_get &block
-
(Enumerable)
-
Other tags:
- Yield: - Yields the table name as a string and a hash
def batch_get &block batch = BatchGet.new(:config => config) yield(batch) batch.enumerator end
def tables
-
(TableCollection)
-
def tables TableCollection.new(:config => config) end