@@ -15,8 +15,6 @@ import { AbstractCursor, assertUninitialized } from './abstract_cursor';
15
15
/** @internal */
16
16
const kFilter = Symbol ( 'filter' ) ;
17
17
/** @internal */
18
- const kNumReturned = Symbol ( 'numReturned' ) ;
19
- /** @internal */
20
18
const kBuiltOptions = Symbol ( 'builtOptions' ) ;
21
19
22
20
/** @public Flags allowed for cursor */
@@ -34,8 +32,6 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
34
32
/** @internal */
35
33
[ kFilter ] : Document ;
36
34
/** @internal */
37
- [ kNumReturned ] ?: number ;
38
- /** @internal */
39
35
[ kBuiltOptions ] : FindOptions ;
40
36
41
37
/** @internal */
@@ -77,39 +73,13 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
77
73
78
74
const response = await executeOperation ( this . client , findOperation ) ;
79
75
80
- // TODO: We only need this for legacy queries that do not support `limit`, maybe
81
- // the value should only be saved in those cases.
82
- if ( response . cursor ) {
83
- this [ kNumReturned ] = response . cursor . firstBatch . length ;
84
- } else {
85
- this [ kNumReturned ] = response . documents ? response . documents . length : 0 ;
86
- }
87
-
88
76
// TODO: NODE-2882
89
77
return { server : findOperation . server , session, response } ;
90
78
}
91
79
92
80
/** @internal */
93
81
override async getMore ( batchSize : number ) : Promise < Document | null > {
94
- // NOTE: this is to support client provided limits in pre-command servers
95
- const numReturned = this [ kNumReturned ] ;
96
- if ( numReturned ) {
97
- const limit = this [ kBuiltOptions ] . limit ;
98
- batchSize =
99
- limit && limit > 0 && numReturned + batchSize > limit ? limit - numReturned : batchSize ;
100
-
101
- if ( batchSize <= 0 ) {
102
- await this . close ( ) . catch ( ( ) => null ) ;
103
- return { cursor : { id : Long . ZERO , nextBatch : [ ] } } ;
104
- }
105
- }
106
-
107
82
const response = await super . getMore ( batchSize ) ;
108
- // TODO: wrap this in some logic to prevent it from happening if we don't need this support
109
- if ( response ) {
110
- this [ kNumReturned ] = this [ kNumReturned ] + response . cursor . nextBatch . length ;
111
- }
112
-
113
83
return response ;
114
84
}
115
85
0 commit comments