Method: MongoDoc::Collection#find

Defined in:
lib/mongo_doc/collection.rb

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



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mongo_doc/collection.rb', line 36

def find(query = {}, options = {})
  retried = false
  begin
    cursor = wrapped_cursor(query, options)
    if block_given?
      yield cursor
      cursor.close
    else
      cursor
    end
  rescue Mongo::ConnectionFailure
    raise if retried
    retried = true
    retry
  end
end