Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/mongo/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ def find(selector={}, opts={})
})

if block_given?
yield cursor
cursor.close
begin
yield cursor
ensure
cursor.close
end
nil
else
cursor
Expand Down Expand Up @@ -594,7 +597,7 @@ def find_and_modify(opts={})

@db.command(cmd)['value']
end

# Perform an aggregation using the aggregation framework on the current collection.
# @note Aggregate requires server version >= 2.1.1
# @note Field References: Within an expression, field names must be quoted and prefixed by a dollar sign ($).
Expand Down Expand Up @@ -636,10 +639,10 @@ def aggregate(pipeline=nil)
unless Mongo::Support.ok?(result)
raise Mongo::OperationFailure, "aggregate failed: #{result['errmsg']}"
end

return result["result"]
end

# Perform a map-reduce operation on the current collection.
#
# @param [String, BSON::Code] map a map function, written in JavaScript.
Expand Down