Skip to content

Commit 8ec9bf5

Browse files
committed
NODE-953 Made batchSize issue general at cursor level
1 parent 7e6ccb2 commit 8ec9bf5

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

lib/collection.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2669,7 +2669,6 @@ Collection.prototype.aggregate = function(pipeline, options, callback) {
26692669
if(this.s.topology.capabilities().hasAggregationCursor) {
26702670
options.cursor = options.cursor || { batchSize : 1000 };
26712671
command.cursor = options.cursor;
2672-
mergeOptions(options, options.cursor);
26732672
}
26742673

26752674
// Allow disk usage command

lib/command_cursor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ inherits(CommandCursor, Readable);
132132

133133
// Set the methods to inherit from prototype
134134
var methodsToInherit = ['_next', 'next', 'each', 'forEach', 'toArray'
135-
, 'rewind', 'bufferedCount', 'readBufferedDocuments', 'close', 'isClosed', 'kill'
135+
, 'rewind', 'bufferedCount', 'readBufferedDocuments', 'close', 'isClosed', 'kill', 'setCursorBatchSize'
136136
, '_find', '_getmore', '_killcursor', 'isDead', 'explain', 'isNotified', 'isKilled'];
137137

138138
// Only inherit the types we need

lib/cursor.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ var Cursor = function(bson, ns, cmd, options, topology, topologyOptions) {
155155

156156
// Set the sort value
157157
this.sortValue = self.s.cmd.sort;
158+
159+
// Get the batchSize
160+
var batchSize = cmd.cursor && cmd.cursor.batchSize
161+
? cmd.cursor && cmd.cursor.batchSize
162+
: (options.cursor && options.cursor.batchSize ? options.cursor.batchSize : 1000);
163+
164+
// Set the batchSize
165+
this.setCursorBatchSize(batchSize);
158166
}
159167

160168
/**

test/functional/aggregation_tests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,8 @@ exports['should maintain batch size between calls to receive new batches'] = {
863863
test.equal(count, 6);
864864
db.close();
865865
test.done();
866+
}).catch(err => {
867+
console.log(err)
866868
});
867869
}
868870
}

0 commit comments

Comments
 (0)