@@ -2494,10 +2494,8 @@ Collection.prototype.aggregate = function(pipeline, options, callback) {
2494
2494
throw toError ( 'cursor options must be an object' ) ;
2495
2495
}
2496
2496
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 ;
2501
2499
2502
2500
// promiseLibrary
2503
2501
options . promiseLibrary = this . s . promiseLibrary ;
@@ -2517,28 +2515,7 @@ Collection.prototype.aggregate = function(pipeline, options, callback) {
2517
2515
return this . s . topology . cursor ( this . s . namespace , command , options ) ;
2518
2516
}
2519
2517
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 ) ) ;
2542
2519
} ;
2543
2520
2544
2521
define . classMethod ( 'aggregate' , { callback : true , promise : false } ) ;
0 commit comments