class AWS::DynamoDB::Item


item = table.items[‘hash-key’,‘range-key’]

Getting an item from a table with both hash and range keys:
item = table.items[‘hash-key-value’]

Getting an item by hash key value:
set.
where the value may be a string, number, string set, or number
of a collection of attributes. Attributes are name/value pairs
complex primary key (according to the table schema) and consists
Represents a DynamoDB item. An item is identified by simple or

def self.new_from(op, response_object, table, *args)

Other tags:
    Api: - private
def self.new_from(op, response_object, table, *args)
  config = args.last.is_a?(Hash) ? args.last : AWS.config
  table.assert_schema!
  hash_value =
    value_from_response(response_object[table.hash_key.name])
  range_value =
    value_from_response(response_object[table.range_key.name]) if
    table.range_key
  raise "missing hash key value in put_item response" unless hash_value
  raise "missing range key value in put_item response" unless
    range_value || !table.range_key
  super(op, response_object,
        table, hash_value, range_value, *args)
end

def attributes

Returns:
  • (AttributeCollection) - An object representing the
def attributes
  AttributeCollection.new(self)
end

def delete(options = {})

Options Hash: (**options)
  • :unless_exists (String, Symbol, Array) -- A name
  • :if (Hash) -- Designates a conditional delete.

Parameters:
  • options (Hash) -- Options for deleting the item.
def delete(options = {})
  client_opts = item_key_options(self)
  expected = expect_conditions(options)
  client_opts[:expected] = expected unless expected.empty?
  client_opts[:return_values] = options[:return].to_s.upcase if
    options[:return]
  resp = client.delete_item(client_opts)
  values_from_response_hash(resp.data["Attributes"]) if
    options[:return] and resp.data["Attributes"]
end

def exists?(options = {})

Returns:
  • (Boolean) - True if the item exists.
def exists?(options = {})
  client_opts = item_key_options(self, options)
  client_opts[:attributes_to_get] = [table.hash_key.name]
  resp = client.get_item(client_opts)
  resp.data.key?("Item")
end

def initialize(table, *args)

Other tags:
    Api: - private
def initialize(table, *args)
  opts = args.pop if args.last.kind_of?(Hash)
  (@hash_value, @range_value) = args
  @table = table
  super(table, opts)
end

def resource_identifiers

def resource_identifiers
  [[:table_name, table.name],
   [:hash_value, hash_value],
   [:range_value, range_value]]
end