Module: Workarea::Api::Admin::DateIndexes

Extended by:
DateIndexes
Included in:
DateIndexes
Defined in:
lib/workarea/api/admin/date_indexes.rb

Instance Method Summary collapse

Instance Method Details

#loadObject

We do this separately from the DateFiltering module to ensure this happens after a model has defined all of its normal indexes. This prevents the date filtering indexes from applying before explicity defined indexes for models that could include options like a TTL.



12
13
14
15
16
17
18
19
# File 'lib/workarea/api/admin/date_indexes.rb', line 12

def load
  ::Mongoid.models.each do |model|
    if model < ApplicationDocument
      model.index({ updated_at: 1 })
      model.index({ created_at: 1 })
    end
  end
end