Sha256: e9ed9a913ed701733a12a4b5fd3c987808a9a664ec2da17bd41448e854e29fd9
Contents?: true
Size: 992 Bytes
Versions: 6
Compression:
Stored size: 992 Bytes
Contents
require 'mongo_doc/criteria' module MongoDoc module Finders def self.extended(base) base.extend(Criteria) unless base === Criteria end # Find a +Document+ based on id (+String+ or +BSON::ObjectId+) # # <tt>Person.find('1')</tt> # <tt>Person.find(obj_id_1, obj_id_2)</tt> def find(*args) criteria.id(*args) end # # Find all +Document+s in the collections # # <tt>Person.find_all</tt> def find_all criteria end # Find a +Document+ based on id (+String+ or +BSON::ObjectId+) # or conditions # # <tt>Person.find_one('1')</tt> # <tt>Person.find_one(:conditions => {:age.gt => 25}, :order_by => [[:name, # :asc]])</tt> def find_one(conditions_or_id) return nil if conditions_or_id.nil? if Hash === conditions_or_id Mongoid::Criteria.translate(self, conditions_or_id).one else Mongoid::Criteria.translate(self, conditions_or_id) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems