Method: Mongoid::Indexable::ClassMethods#create_indexes
- Defined in:
- lib/mongoid/indexable.rb
#create_indexes ⇒ true
Send the actual index creation comments to the MongoDB driver
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mongoid/indexable.rb', line 29 def create_indexes return unless index_specifications index_specifications.each do |spec| key, = spec.key, spec. if database = [:database] with(read: { mode: :primary }, database: database). collection.indexes.create_one(key, .except(:database)) else with(read: { mode: :primary }).collection.indexes.create_one(key, ) end end and true end |