@@ -11,7 +11,7 @@ import type { Hint } from '../operations/operation';
1111import type { ClientSession } from '../sessions' ;
1212import { formatSort , type Sort , type SortDirection } from '../sort' ;
1313import { emitWarningOnce , mergeOptions , type MongoDBNamespace , squashError } from '../utils' ;
14- import { AbstractCursor , assertUninitialized } from './abstract_cursor' ;
14+ import { AbstractCursor } from './abstract_cursor' ;
1515
1616/** @internal */
1717const kFilter = Symbol ( 'filter' ) ;
@@ -163,7 +163,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
163163
164164 /** Set the cursor query */
165165 filter ( filter : Document ) : this {
166- assertUninitialized ( this ) ;
166+ this . throwIfInitialized ( ) ;
167167 this [ kFilter ] = filter ;
168168 return this ;
169169 }
@@ -174,7 +174,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
174174 * @param hint - If specified, then the query system will only consider plans using the hinted index.
175175 */
176176 hint ( hint : Hint ) : this {
177- assertUninitialized ( this ) ;
177+ this . throwIfInitialized ( ) ;
178178 this [ kBuiltOptions ] . hint = hint ;
179179 return this ;
180180 }
@@ -185,7 +185,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
185185 * @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.
186186 */
187187 min ( min : Document ) : this {
188- assertUninitialized ( this ) ;
188+ this . throwIfInitialized ( ) ;
189189 this [ kBuiltOptions ] . min = min ;
190190 return this ;
191191 }
@@ -196,7 +196,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
196196 * @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.
197197 */
198198 max ( max : Document ) : this {
199- assertUninitialized ( this ) ;
199+ this . throwIfInitialized ( ) ;
200200 this [ kBuiltOptions ] . max = max ;
201201 return this ;
202202 }
@@ -209,7 +209,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
209209 * @param value - the returnKey value.
210210 */
211211 returnKey ( value : boolean ) : this {
212- assertUninitialized ( this ) ;
212+ this . throwIfInitialized ( ) ;
213213 this [ kBuiltOptions ] . returnKey = value ;
214214 return this ;
215215 }
@@ -220,7 +220,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
220220 * @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.
221221 */
222222 showRecordId ( value : boolean ) : this {
223- assertUninitialized ( this ) ;
223+ this . throwIfInitialized ( ) ;
224224 this [ kBuiltOptions ] . showRecordId = value ;
225225 return this ;
226226 }
@@ -232,7 +232,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
232232 * @param value - The modifier value.
233233 */
234234 addQueryModifier ( name : string , value : string | boolean | number | Document ) : this {
235- assertUninitialized ( this ) ;
235+ this . throwIfInitialized ( ) ;
236236 if ( name [ 0 ] !== '$' ) {
237237 throw new MongoInvalidArgumentError ( `${ name } is not a valid query modifier` ) ;
238238 }
@@ -295,7 +295,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
295295 * @param value - The comment attached to this query.
296296 */
297297 comment ( value : string ) : this {
298- assertUninitialized ( this ) ;
298+ this . throwIfInitialized ( ) ;
299299 this [ kBuiltOptions ] . comment = value ;
300300 return this ;
301301 }
@@ -306,7 +306,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
306306 * @param value - Number of milliseconds to wait before aborting the tailed query.
307307 */
308308 maxAwaitTimeMS ( value : number ) : this {
309- assertUninitialized ( this ) ;
309+ this . throwIfInitialized ( ) ;
310310 if ( typeof value !== 'number' ) {
311311 throw new MongoInvalidArgumentError ( 'Argument for maxAwaitTimeMS must be a number' ) ;
312312 }
@@ -321,7 +321,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
321321 * @param value - Number of milliseconds to wait before aborting the query.
322322 */
323323 override maxTimeMS ( value : number ) : this {
324- assertUninitialized ( this ) ;
324+ this . throwIfInitialized ( ) ;
325325 if ( typeof value !== 'number' ) {
326326 throw new MongoInvalidArgumentError ( 'Argument for maxTimeMS must be a number' ) ;
327327 }
@@ -371,7 +371,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
371371 * ```
372372 */
373373 project < T extends Document = Document > ( value : Document ) : FindCursor < T > {
374- assertUninitialized ( this ) ;
374+ this . throwIfInitialized ( ) ;
375375 this [ kBuiltOptions ] . projection = value ;
376376 return this as unknown as FindCursor < T > ;
377377 }
@@ -383,7 +383,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
383383 * @param direction - The direction of the sorting (1 or -1).
384384 */
385385 sort ( sort : Sort | string , direction ?: SortDirection ) : this {
386- assertUninitialized ( this ) ;
386+ this . throwIfInitialized ( ) ;
387387 if ( this [ kBuiltOptions ] . tailable ) {
388388 throw new MongoTailableCursorError ( 'Tailable cursor does not support sorting' ) ;
389389 }
@@ -399,7 +399,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
399399 * {@link https://www.mongodb.com/docs/manual/reference/command/find/#find-cmd-allowdiskuse | find command allowDiskUse documentation }
400400 */
401401 allowDiskUse ( allow = true ) : this {
402- assertUninitialized ( this ) ;
402+ this . throwIfInitialized ( ) ;
403403
404404 if ( ! this [ kBuiltOptions ] . sort ) {
405405 throw new MongoInvalidArgumentError ( 'Option "allowDiskUse" requires a sort specification' ) ;
@@ -421,7 +421,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
421421 * @param value - The cursor collation options (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
422422 */
423423 collation ( value : CollationOptions ) : this {
424- assertUninitialized ( this ) ;
424+ this . throwIfInitialized ( ) ;
425425 this [ kBuiltOptions ] . collation = value ;
426426 return this ;
427427 }
@@ -432,7 +432,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
432432 * @param value - The limit for the cursor query.
433433 */
434434 limit ( value : number ) : this {
435- assertUninitialized ( this ) ;
435+ this . throwIfInitialized ( ) ;
436436 if ( this [ kBuiltOptions ] . tailable ) {
437437 throw new MongoTailableCursorError ( 'Tailable cursor does not support limit' ) ;
438438 }
@@ -451,7 +451,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
451451 * @param value - The skip for the cursor query.
452452 */
453453 skip ( value : number ) : this {
454- assertUninitialized ( this ) ;
454+ this . throwIfInitialized ( ) ;
455455 if ( this [ kBuiltOptions ] . tailable ) {
456456 throw new MongoTailableCursorError ( 'Tailable cursor does not support skip' ) ;
457457 }
0 commit comments