Module: Humanoid::Indexes::ClassMethods

Defined in:
lib/humanoid/indexes.rb

Overview

:nodoc

Instance Method Summary collapse

Instance Method Details

#add_indexesObject

Add the default indexes to the root document if they do not already exist. Currently this is only _type.



16
17
18
19
20
21
# File 'lib/humanoid/indexes.rb', line 16

def add_indexes
  unless indexed
    self._collection.create_index(:_type, false)
    self.indexed = true
  end
end

#index(name, options = { :unique => false }) ⇒ Object

Adds an index on the field specified. Options can be :unique => true or :unique => false. It will default to the latter.



25
26
27
# File 'lib/humanoid/indexes.rb', line 25

def index(name, options = { :unique => false })
  collection.create_index(name, options[:unique])
end