Class AWS::DynamoDB::Item
In: lib/aws/dynamo_db/item.rb
Parent: Core::Resource

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

Getting an item by hash key value:

  item = table.items['hash-key-value']

Getting an item from a table with both hash and range keys:

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

Methods

Included Modules

Keys Expectations

Attributes

hash_value  [R]  @return [String, Numeric] The hash key value of the item.
range_value  [R]  @return [String, Numeric, nil] The range key value of the
  item, or +nil+ if the table has a simple primary key.
table  [R]  @return [Table] The table in which the item is stored.

Public Class methods

Public Instance methods

@return [AttributeCollection] An object representing the

  attributes of the item.

Deletes the item.

@param [Hash] options Options for deleting the item.

@option options [Hash] :if Designates a conditional delete.

  The operation will fail unless the item exists and has the
  attributes in the value for this option.  For example:

    # throws DynamoDB::Errors::ConditionalCheckFailedException
    # unless the item has "color" set to "red"
    item.delete(:if => { :color => "red" })

@option options [String, Symbol, Array] :unless_exists A name

  or collection of attribute names; if the item has a value
  for any of these attributes, this method will raise
  +DynamoDB::Errors::ConditionalCheckFailedException+.  For
  example:

    item.delete(:unless_exists => "version")

@return [Boolean] True if the item exists.

Protected Instance methods

[Validate]