Module: AWS::DynamoDB::Keys

Includes:
Types
Included in:
AttributeCollection, BatchGet, Item
Defined in:
lib/aws/dynamo_db/keys.rb

Instance Method Summary collapse

Methods included from Types

#format_attribute_value, #value_from_response, #values_from_response_hash

Instance Method Details

#item_key_hash(item) ⇒ Hash

Returns just the hash key element and range key element

Returns:

  • (Hash)

    Returns just the hash key element and range key element



29
30
31
32
33
34
35
36
# File 'lib/aws/dynamo_db/keys.rb', line 29

def item_key_hash item
  item.table.assert_schema!
  key = {}
  key[:hash_key_element] = format_attribute_value(item.hash_value)
  key[:range_key_element] = format_attribute_value(item.range_value) if
    item.table.composite_key?
  key
end

#item_key_options(item, extra = {}) ⇒ Hash

Returns Client options for identifying an item.

Returns:

  • (Hash)

    Client options for identifying an item.



23
24
25
26
# File 'lib/aws/dynamo_db/keys.rb', line 23

def item_key_options(item, extra = {})
  key = item_key_hash(item)
  extra.merge({ :table_name => item.table.name, :key => key })
end