Module: Dynomite::Item::Indexes

Defined in:
lib/dynomite/item/indexes.rb,
lib/dynomite/item/indexes/index.rb,
lib/dynomite/item/indexes/finder.rb,
lib/dynomite/item/indexes/primary_index.rb

Defined Under Namespace

Classes: Finder, Index, PrimaryIndex

Instance Method Summary collapse

Instance Method Details

#global_secondary_indexesObject



20
21
22
23
# File 'lib/dynomite/item/indexes.rb', line 20

def global_secondary_indexes
  table = desc_table(table_name)
  table.global_secondary_indexes.to_a.select { |i| i.index_status == "ACTIVE" }
end

#index_namesObject



3
4
5
# File 'lib/dynomite/item/indexes.rb', line 3

def index_names
  indexes.map(&:index_name)
end

#indexesObject

Sorted by indexes with composite keys with partition and sort keys first so they take priority for Indexes::Finder#find



9
10
11
12
13
# File 'lib/dynomite/item/indexes.rb', line 9

def indexes
  lsi = local_secondary_indexes.map { |i| Index.new(i) }.sort_by { |i| i.fields.size * -1 }
  gsi = global_secondary_indexes.map { |i| Index.new(i) }.sort_by { |i| i.fields.size * -1 }
  lsi + gsi
end

#local_secondary_indexesObject



15
16
17
18
# File 'lib/dynomite/item/indexes.rb', line 15

def local_secondary_indexes
  table = desc_table(table_name)
  table.local_secondary_indexes.to_a
end