Class: EM::Mongo::Collection
- Inherits:
-
Object
- Object
- EM::Mongo::Collection
- Defined in:
- lib/em-synchrony/em-mongo.rb
Instance Method Summary collapse
- #afind ⇒ Object
- #afirst ⇒ Object
- #find(selector = {}, opts = {}) ⇒ Object
- #first(selector = {}, opts = {}) ⇒ Object
Instance Method Details
#afind ⇒ Object
25 |
# File 'lib/em-synchrony/em-mongo.rb', line 25 alias :afind :find |
#afirst ⇒ Object
38 |
# File 'lib/em-synchrony/em-mongo.rb', line 38 alias :afirst :first |
#find(selector = {}, opts = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/em-synchrony/em-mongo.rb', line 26 def find(selector={}, opts={}) f = Fiber.current cb = proc { |res| f.resume(res) } skip = opts.delete(:skip) || 0 limit = opts.delete(:limit) || 0 @connection.find(@name, skip, limit, selector, nil, &cb) Fiber.yield end |
#first(selector = {}, opts = {}) ⇒ Object
39 40 41 42 |
# File 'lib/em-synchrony/em-mongo.rb', line 39 def first(selector={}, opts={}) opts[:limit] = 1 find(selector, opts).first end |