Module: MongoMapper::Plugins::Indexes::ClassMethods

Defined in:
lib/mongo_mapper/plugins/indexes.rb

Instance Method Summary collapse

Instance Method Details

#create_index(spec, options = {}) ⇒ Object



13
14
15
# File 'lib/mongo_mapper/plugins/indexes.rb', line 13

def create_index(spec, options = {})
  collection.indexes.create_one dealias_options(spec), options
end

#drop_index(name) ⇒ Object



17
18
19
# File 'lib/mongo_mapper/plugins/indexes.rb', line 17

def drop_index(name)
  collection.indexes.drop_one name
end

#drop_indexesObject



21
22
23
# File 'lib/mongo_mapper/plugins/indexes.rb', line 21

def drop_indexes
  collection.indexes.drop_all
end

#ensure_index(spec, options = {}) ⇒ Object



8
9
10
11
# File 'lib/mongo_mapper/plugins/indexes.rb', line 8

def ensure_index(spec, options = {})
  #TODO: should we emulate the mongo 1.x behaviour of caching attempts to create indexes?
  collection.indexes.create_one dealias_options(spec), options
end