Class AWS::DynamoDB::TableCollection
In: lib/aws/dynamo_db/table_collection.rb
Parent: Object

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]

@example Creating a Table

  table = dynamo_db.tables.create('mytable', 10, 10, :hash_key => { :id => :string })

@example Enumerating Tables

  dynamo_db.tables.each {|table| puts table.name }

@example Getting a Table by Name

  table = dynamo_db.tables['mytable']

Methods

[]   _each_item   create  

Included Modules

Core::Collection::Limitable

Public Instance methods

References a table by name.

  dynamo_db.tables["MyTable"]

@param [String] name @return [Table] Returns the table with the given name.

Creates a new table.

  table = dynamo_db.tables.create('mytable', 25, 25,
    :hash_key => { :id => :string })

@note Creating a table is an eventualy consistent operation. You

  can not interact with the table until its status
  ({Table#status}) is +:active+.

@param [String] name The name of the table.

@param [Integer] read_capacity_units Sets the minimum

  number of reads supported before read requests are throttled.

@param [Integer] write_capacity_units Sets the minimum

  number of writes supported before writes requests are throttled.

@param [Hash] options

@option options [Hash] :hash_key A hash key is a combination

  of an attribute name and type.  If you want to have the
  hash key on the string attribute username you would call #create
  with:

     :hash_key => { :username => :string }

  The other supported type is +:number+.  If you wanted to
  set the hash key on a numeric (integer) attribute then you
  could call #create with:

     :hash_key => { :id => :number }

  All tables require a hash key.  If +:hash_key+ is not provided
  then a default hash key will be provided.  The default hash
  key is:

     :hash_key => { :id => :string }

@option options [String] :range_key You can setup a table to use

  composite keys by providing a +:range_key+.  Range keys are
  configured the same way as hash keys.  They are useful
  for ordering items that share the same hash key.

@return [Table] The newly created table.

Protected Instance methods

[Validate]