Indexing
A common drawback with object databases is that you have to iterate over every object to find ones that fit certain criteria.
In HybridDb you use the indexes class method to index a property (instance variable) of your class.
class User < HybridObject
indexes :name
attr_accessor :name, :department
end
This allows you to use conditions in your find calls
User.find(:all, :conditions => {:name => 'Jimmy Joe'}) # finds all users named Jimmy joe
Only properties that are marked for indexing can be used in finders, to search for non-indexed properties, (which will require a full scan) you need to load and check each object.
The conditions hash can have multiple property / value pairs, which are anded together.
Re-indexing
If, during development of your application, you set a property of your class as indexed, that wasn’t indexed before, you will need to recreate the indexes for the objects that were saved prior to the property being marked as indexed.
User.find(:all).each {|u| u.recreate_indexes }