Class: AWS::DynamoDB::TableCollection
- Inherits:
-
Object
- Object
- AWS::DynamoDB::TableCollection
- Includes:
- Core::Collection::Limitable
- Defined in:
- lib/aws/dynamo_db/table_collection.rb
Overview
Represents the tables in your account. Each table is represented by an instance of the Table class.
Schemas
Before you can operate on items in a table you must specify the schema. You do this by calling #hash_key= (and optionally #range_key=) on a table.
table = dynamo_db.tables['mytable']
table.hash_key = [:id, :string]
Instance Attribute Summary
Attributes included from Core::Model
Instance Method Summary collapse
-
#[](name) ⇒ Table
References a table by name.
-
#create(name, read_capacity_units, write_capacity_units, options = {}) ⇒ Table
Creates a new table.
Methods included from Core::Collection::Limitable
Methods included from Core::Collection
#each, #each_batch, #enum, #first, #in_groups_of, #page
Methods included from Core::Model
#client, #config_prefix, #initialize, #inspect
Instance Method Details
#[](name) ⇒ Table
References a table by name.
dynamo_db.tables["MyTable"]
110 111 112 |
# File 'lib/aws/dynamo_db/table_collection.rb', line 110 def [] name Table.new(name, :config => config) end |
#create(name, read_capacity_units, write_capacity_units, options = {}) ⇒ Table
Note:
Creating a table is an eventualy consistent operation. You can not interact with the table until its status (AWS::DynamoDB::Table#status) is :active
.
Creates a new table.
table = dynamo_db.tables.create('mytable', 25, 25,
:hash_key => { :id => :string })
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/aws/dynamo_db/table_collection.rb', line 87 def create name, read_capacity_units, write_capacity_units, = {} client_opts = { :table_name => name.to_s, :key_schema => key_schema(), :provisioned_throughput => { :read_capacity_units => read_capacity_units, :write_capacity_units => write_capacity_units, }, } response = client.create_table(client_opts) Table.new(name, :config => config) end |