@@ -34,7 +34,7 @@ const util = require('util');
3434 * @api public
3535 */
3636
37- function QueryCursor ( query , options ) {
37+ function QueryCursor ( query ) {
3838 // set autoDestroy=true because on node 12 it's by default false
3939 // gh-10902 need autoDestroy to destroy correctly and emit 'close' event
4040 Readable . call ( this , { autoDestroy : true , objectMode : true } ) ;
@@ -46,7 +46,7 @@ function QueryCursor(query, options) {
4646 this . _mongooseOptions = { } ;
4747 this . _transforms = [ ] ;
4848 this . model = model ;
49- this . options = options || { } ;
49+ this . options = { } ;
5050 model . hooks . execPre ( 'find' , query , ( err ) => {
5151 if ( err != null ) {
5252 if ( err instanceof kareem . skipWrappedFunction ) {
@@ -70,20 +70,18 @@ function QueryCursor(query, options) {
7070 this . listeners ( 'error' ) . length > 0 && this . emit ( 'error' , err ) ;
7171 return ;
7272 }
73+ Object . assign ( this . options , query . _optionsForExec ( ) ) ;
7374 this . _transforms = this . _transforms . concat ( query . _transforms . slice ( ) ) ;
7475 if ( this . options . transform ) {
75- this . _transforms . push ( options . transform ) ;
76+ this . _transforms . push ( this . options . transform ) ;
7677 }
7778 // Re: gh-8039, you need to set the `cursor.batchSize` option, top-level
7879 // `batchSize` option doesn't work.
7980 if ( this . options . batchSize ) {
80- this . options . cursor = options . cursor || { } ;
81- this . options . cursor . batchSize = options . batchSize ;
82-
8381 // Max out the number of documents we'll populate in parallel at 5000.
8482 this . options . _populateBatchSize = Math . min ( this . options . batchSize , 5000 ) ;
8583 }
86- Object . assign ( this . options , query . _optionsForExec ( ) ) ;
84+
8785 if ( model . collection . _shouldBufferCommands ( ) && model . collection . buffer ) {
8886 model . collection . queue . push ( [
8987 ( ) => _getRawCursor ( query , this )
0 commit comments