File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
8181 // the response is not a cursor when `explain` is enabled
8282 if ( CursorResponse . is ( response ) ) {
8383 this [ kNumReturned ] = response . batchSize ;
84+ } else {
85+ // Can be an explain response, hence the ?. on everything
86+ this [ kNumReturned ] = this [ kNumReturned ] + ( response ?. cursor ?. firstBatch ?. length ?? 0 ) ;
8487 }
8588
8689 // TODO: NODE-2882
@@ -114,10 +117,12 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
114117 }
115118 }
116119
117- const response = await super . getMore ( batchSize , this . client . autoEncrypter ? false : true ) ;
120+ const response = await super . getMore ( batchSize , false ) ;
118121 // TODO: wrap this in some logic to prevent it from happening if we don't need this support
119122 if ( CursorResponse . is ( response ) ) {
120123 this [ kNumReturned ] = this [ kNumReturned ] + response . batchSize ;
124+ } else {
125+ this [ kNumReturned ] = this [ kNumReturned ] + ( response ?. cursor ?. nextBatch ?. length ?? 0 ) ;
121126 }
122127
123128 return response ;
Original file line number Diff line number Diff line change 11import type { Document } from '../bson' ;
2- import { CursorResponse } from '../cmap/wire_protocol/responses' ;
32import { MongoInvalidArgumentError } from '../error' ;
43import { ReadConcern } from '../read_concern' ;
54import type { Server } from '../sdam/server' ;
@@ -115,7 +114,7 @@ export class FindOperation extends CommandOperation<Document> {
115114 documentsReturnedIn : 'firstBatch' ,
116115 session
117116 } ,
118- this . explain ? undefined : CursorResponse
117+ undefined
119118 ) ;
120119 }
121120}
You can’t perform that action at this time.
0 commit comments