Class: EM::Mongo::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/em-synchrony/em-mongo.rb

Instance Method Summary collapse

Instance Method Details

#afindObject



25
# File 'lib/em-synchrony/em-mongo.rb', line 25

alias :afind :find

#afirstObject



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