Class: Faststep::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/faststep/collection.rb,
ext/faststep/collection.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObject

Instance Attribute Details

#nameObject (readonly)

Instance Method Details

#countObject

#create_indexObject

#dropObject

#find(selector = {}, options = {}) ⇒ Object



3
4
5
# File 'lib/faststep/collection.rb', line 3

def find(selector = {}, options = {})
  Cursor.new(self, "selector" => selector)
end

#find_one(spec_or_object_id = nil, opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/faststep/collection.rb', line 7

def find_one(spec_or_object_id=nil, opts={})
  spec = case spec_or_object_id
         when nil
           {}
         when BSON::ObjectId
           {:_id => spec_or_object_id}
         when Hash
           spec_or_object_id
         else
           raise TypeError, "spec_or_object_id must be an instance of ObjectId or Hash, or nil"
         end
  find(spec, opts.merge(:limit => -1)).first
end

#insertObject

#nsObject

#removeObject

#updateObject