@@ -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
25442521define . classMethod ( 'aggregate' , { callback : true , promise : false } ) ;
0 commit comments