MCPcopy
hub / github.com/mongodb/node-mongodb-native / hasNext

Function hasNext

src/cursor/abstract_cursor.ts:527–551  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

525 }
526
527 async hasNext(): Promise<boolean> {
528 this.signal?.throwIfAborted();
529
530 if (this.cursorId === Long.ZERO) {
531 return false;
532 }
533
534 if (this.cursorOptions.timeoutMode === CursorTimeoutMode.ITERATION && this.cursorId != null) {
535 this.timeoutContext?.refresh();
536 }
537 try {
538 do {
539 if ((this.documents?.length ?? 0) !== 0) {
540 return true;
541 }
542 await this.fetchBatch();
543 } while (!this.isDead || (this.documents?.length ?? 0) !== 0);
544 } finally {
545 if (this.cursorOptions.timeoutMode === CursorTimeoutMode.ITERATION) {
546 this.timeoutContext?.clear();
547 }
548 }
549
550 return false;
551 }
552
553 /** Get the next available document from the cursor, returns null if no more documents are available. */
554 async next(): Promise<TSchema | null> {

Callers

nothing calls this directly

Calls 3

throwIfAbortedMethod · 0.80
refreshMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected