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> {
81
81
// the response is not a cursor when `explain` is enabled
82
82
if (CursorResponse.is(response)) {
83
83
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);
84
87
}
85
88
86
89
// TODO: NODE-2882
@@ -114,10 +117,12 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
114
117
}
115
118
}
116
119
117
- const response = await super.getMore(batchSize, this.client.autoEncrypter ? false : true );
120
+ const response = await super.getMore(batchSize, false);
118
121
// TODO: wrap this in some logic to prevent it from happening if we don't need this support
119
122
if (CursorResponse.is(response)) {
120
123
this[kNumReturned] = this[kNumReturned] + response.batchSize;
124
+ } else {
125
+ this[kNumReturned] = this[kNumReturned] + (response?.cursor?.nextBatch?.length ?? 0);
121
126
}
122
127
123
128
return response;
Original file line number Diff line number Diff line change 1
1
import type { Document } from '../bson';
2
- import { CursorResponse } from '../cmap/wire_protocol/responses';
3
2
import { MongoInvalidArgumentError } from '../error';
4
3
import { ReadConcern } from '../read_concern';
5
4
import type { Server } from '../sdam/server';
@@ -115,7 +114,7 @@ export class FindOperation extends CommandOperation<Document> {
115
114
documentsReturnedIn: 'firstBatch',
116
115
session
117
116
},
118
- this.explain ? undefined : CursorResponse
117
+ undefined
119
118
);
120
119
}
121
120
}
You can’t perform that action at this time.
0 commit comments