Method: OceanDynamo::Tables::ClassMethods#table_attribute_definitions

Defined in:
lib/ocean-dynamo/tables.rb

#table_attribute_definitionsObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/ocean-dynamo/tables.rb', line 133

def table_attribute_definitions
  attrs = []
  attrs << { attribute_name: table_hash_key.to_s, attribute_type: attribute_type(table_hash_key) }
  attrs << { attribute_name: table_range_key.to_s, attribute_type: attribute_type(table_range_key) }  if table_range_key
  local_secondary_indexes.each do |name|
    attrs << { attribute_name: name, attribute_type: attribute_type(name) }
  end
  global_secondary_indexes.each do |index_name, data|
    data["keys"].each do |name| 
      next if attrs.any? { |a| a[:attribute_name] == name }
      attrs << { attribute_name: name, attribute_type: attribute_type(name) }
    end
  end
  attrs
end