Module: Aws::Record::SecondaryIndexes::SecondaryIndexesClassMethods

Included in:
Aws::Record
Defined in:
lib/aws-record/record/secondary_indexes.rb

Instance Method Summary collapse

Instance Method Details

#global_secondary_index(name, opts) ⇒ Object

Creates a global secondary index for the model. Learn more about Global Secondary Indexes in the Amazon DynamoDB Developer Guide.

Note: #global_secondary_indexes is inherited from a parent model when global_secondary_index is explicitly specified in the parent.

Parameters:

  • name (Symbol) —

    index name for this global secondary index

  • opts (Hash)

Options Hash (opts):

  • :hash_key (Symbol) —

    the hash key used by this global secondary index.

  • :range_key (Symbol) —

    the range key used by this global secondary index.

  • :projection (Hash) —

    a hash which defines which attributes are copied from the table to the index. See shape details in the AWS SDK for Ruby V3 docs.



59
60
61
62
# File 'lib/aws-record/record/secondary_indexes.rb', line 59

def global_secondary_index(name, opts)
  _validate_required_gsi_keys(opts)
  global_secondary_indexes[name] = opts
end

#global_secondary_indexes ⇒ Hash

Returns hash of global secondary index names to the index's attributes.

Note: global_secondary_indexes is inherited from a parent model when #global_secondary_index is explicitly specified in the parent.

Returns:

  • (Hash) —

    hash of global secondary index names to the index's attributes.



80
81
82
# File 'lib/aws-record/record/secondary_indexes.rb', line 80

def global_secondary_indexes
  @global_secondary_indexes
end

#global_secondary_indexes_for_migration ⇒ Hash

Returns hash of the global secondary indexes in a form suitable for use in a table migration. For example, any attributes which have a unique database storage name will use that name instead.

Returns:

  • (Hash) —

    hash of the global secondary indexes in a form suitable for use in a table migration. For example, any attributes which have a unique database storage name will use that name instead.



94
95
96
# File 'lib/aws-record/record/secondary_indexes.rb', line 94

def global_secondary_indexes_for_migration
  _migration_format_indexes(global_secondary_indexes)
end

#local_secondary_index(name, opts) ⇒ Object

Creates a local secondary index for the model. Learn more about Local Secondary Indexes in the Amazon DynamoDB Developer Guide.

Note: #local_secondary_indexes is inherited from a parent model when local_secondary_index is explicitly specified in the parent.

Parameters:

  • name (Symbol) —

    index name for this local secondary index

  • opts (Hash)

Options Hash (opts):

  • :range_key (Symbol) —

    the range key used by this local secondary index. Note that the hash key MUST be the table's hash key, and so that value will be filled in for you.

  • :projection (Hash) —

    a hash which defines which attributes are copied from the table to the index. See shape details in the AWS SDK for Ruby V3 docs.



38
39
40
41
42
# File 'lib/aws-record/record/secondary_indexes.rb', line 38

def local_secondary_index(name, opts)
  opts[:hash_key] = hash_key
  _validate_required_lsi_keys(opts)
  local_secondary_indexes[name] = opts
end

#local_secondary_indexes ⇒ Hash

Returns hash of local secondary index names to the index's attributes.

Note: local_secondary_indexes is inherited from a parent model when #local_secondary_index is explicitly specified in the parent.

Returns:

  • (Hash) —

    hash of local secondary index names to the index's attributes.



70
71
72
# File 'lib/aws-record/record/secondary_indexes.rb', line 70

def local_secondary_indexes
  @local_secondary_indexes
end

#local_secondary_indexes_for_migration ⇒ Hash

Returns hash of the local secondary indexes in a form suitable for use in a table migration. For example, any attributes which have a unique database storage name will use that name instead.

Returns:

  • (Hash) —

    hash of the local secondary indexes in a form suitable for use in a table migration. For example, any attributes which have a unique database storage name will use that name instead.



87
88
89
# File 'lib/aws-record/record/secondary_indexes.rb', line 87

def local_secondary_indexes_for_migration
  _migration_format_indexes(local_secondary_indexes)
end