Method: AWS::DynamoDB::BatchWrite#put

Defined in:
lib/aws/dynamo_db/batch_write.rb

#put(table, items) ⇒ nil

Adds one or more items to the batch write operation.

# adding one item at a time to the batch
batch = AWS::DynamoDB::BatchWrite.new
batch.put('table-name', :id => 'id1', :color => 'red')
batch.put('table-name', :id => 'id2', :color => 'blue')
batch.process!

# adding multiple items to a batch
batch = AWS::DynamoDB::BatchWrite.new
batch.put('table-name', [
  { :id => 'id1', :color => 'red' },
  { :id => 'id2', :color => 'blue' },
  { :id => 'id3', :color => 'green' },
])
batch.process!

Parameters:

  • table (Table, String)

    A Table object or table name string.

  • items (Array<Hash>)

    A list of item attributes to put. The hash must contain the table hash key element and range key element (if one is defined).

Returns:

  • (nil)


51
52
53
54
# File 'lib/aws/dynamo_db/batch_write.rb', line 51

def put table, items
  write(table, :put => items.flatten)
  nil
end