Skip to content

Commit 84457ec

Browse files
authored
fix(aggregate): remove support for inline results for aggregate (#1620)
Per DRIVERS-350, All aggregation commands must either include the 'cursor' option or 'explain':true. Fixes NODE-1224
1 parent 35d2d3e commit 84457ec

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

lib/collection.js

+3-26
Original file line numberDiff line numberDiff line change
@@ -2494,10 +2494,8 @@ Collection.prototype.aggregate = function(pipeline, options, callback) {
24942494
throw toError('cursor options must be an object');
24952495
}
24962496

2497-
if (this.s.topology.capabilities().hasAggregationCursor) {
2498-
options.cursor = options.cursor || { batchSize: 1000 };
2499-
command.cursor = options.cursor;
2500-
}
2497+
options.cursor = options.cursor || { batchSize: 1000 };
2498+
command.cursor = options.cursor;
25012499

25022500
// promiseLibrary
25032501
options.promiseLibrary = this.s.promiseLibrary;
@@ -2517,28 +2515,7 @@ Collection.prototype.aggregate = function(pipeline, options, callback) {
25172515
return this.s.topology.cursor(this.s.namespace, command, options);
25182516
}
25192517

2520-
if (options.cursor) {
2521-
return handleCallback(
2522-
callback,
2523-
null,
2524-
this.s.topology.cursor(this.s.namespace, command, options)
2525-
);
2526-
}
2527-
2528-
// For legacy server versions, we execute the command and format the result
2529-
this.s.db.command(command, options, function(err, result) {
2530-
if (err) {
2531-
handleCallback(callback, err);
2532-
} else if (result['err'] || result['errmsg']) {
2533-
handleCallback(callback, toError(result));
2534-
} else if (typeof result === 'object' && result['serverPipeline']) {
2535-
handleCallback(callback, null, result['serverPipeline']);
2536-
} else if (typeof result === 'object' && result['stages']) {
2537-
handleCallback(callback, null, result['stages']);
2538-
} else {
2539-
handleCallback(callback, null, result.result);
2540-
}
2541-
});
2518+
return handleCallback(callback, null, this.s.topology.cursor(this.s.namespace, command, options));
25422519
};
25432520

25442521
define.classMethod('aggregate', { callback: true, promise: false });

0 commit comments

Comments
 (0)