Module: Ripple::Indexes::DocumentMethods::ClassMethods

Defined in:
lib/ripple/indexes.rb

Instance Method Summary collapse

Instance Method Details

#find_by_index(index_name, query) ⇒ Object

Search for a document using an indexed column

Parameters:



84
85
86
87
88
89
90
91
92
# File 'lib/ripple/indexes.rb', line 84

def find_by_index(index_name, query)
  if ["$bucket", "$key"].include?(index_name.to_s)
    self.find(Ripple.client.get_index(self.bucket.name, index_name.to_s, query))
  else
    idx = self.indexes[index_name]
    raise ArgumentError, t('index_undefined', :property => index_name, :type => self.name) if idx.nil?
    self.find(Ripple.client.get_index(self.bucket.name, idx.index_key, query))
  end
end