Module: Humanoid::Indexes::ClassMethods
- Defined in:
- lib/humanoid/indexes.rb
Overview
:nodoc
Instance Method Summary collapse
-
#add_indexes ⇒ Object
Add the default indexes to the root document if they do not already exist.
-
#index(name, options = { :unique => false }) ⇒ Object
Adds an index on the field specified.
Instance Method Details
#add_indexes ⇒ Object
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, = { :unique => false }) collection.create_index(name, [:unique]) end |