You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param value - The number of documents to return per batch. See {@link https://docs.mongodb.com/manual/reference/command/find/|find command documentation}.
454
461
*/
455
462
batchSize(value: number): this {
463
+
assertUninitialized(this);
456
464
if(this[kOptions].tailable){
457
465
thrownewMongoError('Tailable cursors do not support batchSize');
...this[kBuiltOptions],// NOTE: order matters here, we may need to refine this
56
55
...this.cursorOptions,
@@ -143,6 +142,7 @@ export class FindCursor extends AbstractCursor {
143
142
144
143
/** Set the cursor query */
145
144
filter(filter: Document): this {
145
+
assertUninitialized(this);
146
146
this[kFilter]=filter;
147
147
returnthis;
148
148
}
@@ -153,6 +153,7 @@ export class FindCursor extends AbstractCursor {
153
153
* @param hint - If specified, then the query system will only consider plans using the hinted index.
154
154
*/
155
155
hint(hint: Hint): this {
156
+
assertUninitialized(this);
156
157
this[kBuiltOptions].hint=hint;
157
158
returnthis;
158
159
}
@@ -163,6 +164,7 @@ export class FindCursor extends AbstractCursor {
163
164
* @param min - Specify a $min value to specify the inclusive lower bound for a specific index in order to constrain the results of find(). The $min specifies the lower bound for all keys of a specific index in order.
164
165
*/
165
166
min(min: number): this {
167
+
assertUninitialized(this);
166
168
this[kBuiltOptions].min=min;
167
169
returnthis;
168
170
}
@@ -173,6 +175,7 @@ export class FindCursor extends AbstractCursor {
173
175
* @param max - Specify a $max value to specify the exclusive upper bound for a specific index in order to constrain the results of find(). The $max specifies the upper bound for all keys of a specific index in order.
174
176
*/
175
177
max(max: number): this {
178
+
assertUninitialized(this);
176
179
this[kBuiltOptions].max=max;
177
180
returnthis;
178
181
}
@@ -185,6 +188,7 @@ export class FindCursor extends AbstractCursor {
185
188
* @param value - the returnKey value.
186
189
*/
187
190
returnKey(value: boolean): this {
191
+
assertUninitialized(this);
188
192
this[kBuiltOptions].returnKey=value;
189
193
returnthis;
190
194
}
@@ -195,6 +199,7 @@ export class FindCursor extends AbstractCursor {
195
199
* @param value - The $showDiskLoc option has now been deprecated and replaced with the showRecordId field. $showDiskLoc will still be accepted for OP_QUERY stye find.
196
200
*/
197
201
showRecordId(value: boolean): this {
202
+
assertUninitialized(this);
198
203
this[kBuiltOptions].showRecordId=value;
199
204
returnthis;
200
205
}
@@ -206,6 +211,7 @@ export class FindCursor extends AbstractCursor {
206
211
* @param value - The modifier value.
207
212
*/
208
213
addQueryModifier(name: string,value: string|boolean|number|Document): this {
214
+
assertUninitialized(this);
209
215
if(name[0]!=='$'){
210
216
thrownewMongoError(`${name} is not a valid query modifier`);
211
217
}
@@ -268,6 +274,7 @@ export class FindCursor extends AbstractCursor {
268
274
* @param value - The comment attached to this query.
269
275
*/
270
276
comment(value: string): this {
277
+
assertUninitialized(this);
271
278
this[kBuiltOptions].comment=value;
272
279
returnthis;
273
280
}
@@ -278,6 +285,7 @@ export class FindCursor extends AbstractCursor {
278
285
* @param value - Number of milliseconds to wait before aborting the tailed query.
279
286
*/
280
287
maxAwaitTimeMS(value: number): this {
288
+
assertUninitialized(this);
281
289
if(typeofvalue!=='number'){
282
290
thrownewMongoError('maxAwaitTimeMS must be a number');
283
291
}
@@ -292,6 +300,7 @@ export class FindCursor extends AbstractCursor {
292
300
* @param value - Number of milliseconds to wait before aborting the query.
293
301
*/
294
302
maxTimeMS(value: number): this {
303
+
assertUninitialized(this);
295
304
if(typeofvalue!=='number'){
296
305
thrownewMongoError('maxTimeMS must be a number');
297
306
}
@@ -306,6 +315,7 @@ export class FindCursor extends AbstractCursor {
306
315
* @param value - The field projection object.
307
316
*/
308
317
project(value: Document): this {
318
+
assertUninitialized(this);
309
319
this[kBuiltOptions].projection=value;
310
320
returnthis;
311
321
}
@@ -317,6 +327,7 @@ export class FindCursor extends AbstractCursor {
317
327
* @param direction - The direction of the sorting (1 or -1).
318
328
*/
319
329
sort(sort: Sort|string,direction?: SortDirection): this {
330
+
assertUninitialized(this);
320
331
if(this[kBuiltOptions].tailable){
321
332
thrownewMongoError('Tailable cursor does not support sorting');
322
333
}
@@ -331,6 +342,7 @@ export class FindCursor extends AbstractCursor {
331
342
* @param value - The cursor collation options (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
332
343
*/
333
344
collation(value: CollationOptions): this {
345
+
assertUninitialized(this);
334
346
this[kBuiltOptions].collation=value;
335
347
returnthis;
336
348
}
@@ -341,12 +353,13 @@ export class FindCursor extends AbstractCursor {
341
353
* @param value - The limit for the cursor query.
342
354
*/
343
355
limit(value: number): this {
356
+
assertUninitialized(this);
344
357
if(this[kBuiltOptions].tailable){
345
358
thrownewMongoError('Tailable cursor does not support limit');
346
359
}
347
360
348
361
if(typeofvalue!=='number'){
349
-
thrownewMongoError('limit requires an integer');
362
+
thrownewTypeError('limit requires an integer');
350
363
}
351
364
352
365
this[kBuiltOptions].limit=value;
@@ -359,12 +372,13 @@ export class FindCursor extends AbstractCursor {
359
372
* @param value - The skip for the cursor query.
360
373
*/
361
374
skip(value: number): this {
375
+
assertUninitialized(this);
362
376
if(this[kBuiltOptions].tailable){
363
377
thrownewMongoError('Tailable cursor does not support skip');
0 commit comments