Skip to content

Commit 092f4f2

Browse files
committed
Merge branch 'master' of https://github.com/schaermu/node-mongodb-native into schaermu-master
2 parents ab03b8c + 478f327 commit 092f4f2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/mongodb/collection.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,18 @@ Collection.prototype.mapReduce = function(map, reduce, options, callback) {
494494
if(err == null && result.documents[0].ok == 1) {
495495
// Create a collection object that wraps the result collection
496496
self.db.collection(result.documents[0].result, function(err, collection) {
497-
callback(err, collection);
497+
if(options.include_statistics) {
498+
var stats = {
499+
processtime: result.documents[0].timeMillis,
500+
counts: result.documents[0].counts
501+
};
502+
callback(err, collection, stats);
503+
} else {
504+
callback(err, collection);
505+
}
498506
});
499507
} else {
500-
err != null ? callback(err, null) : callback(new Error("map-reduce failed: " + result.documents[0].errmsg), null);
508+
err != null ? callback(err, null, null) : callback(new Error("map-reduce failed: " + result.documents[0].errmsg), null, null);
501509
}
502510
});
503511
};

0 commit comments

Comments
 (0)