lib/mongo/operation/map_reduce/result.rb in mongo-2.17.4 vs lib/mongo/operation/map_reduce/result.rb in mongo-2.18.0.beta1
- old
+ new
@@ -129,9 +129,25 @@
# @api private
def cursor_id
0
end
+ # Get the number of documents returned by the server in this batch.
+ #
+ # Map/Reduce operation returns documents inline without using
+ # cursors; as such, the standard Mongo::Reply#returned_count does
+ # not work correctly for Map/Reduce.
+ #
+ # Note that the Map/Reduce operation is limited to max BSON document
+ # size (16 MB) in its inline result set.
+ #
+ # @return [ Integer ] The number of documents returned.
+ #
+ # @api public
+ def returned_count
+ reply.documents.length
+ end
+
private
def first_document
@first_document ||= reply.documents[0]
end