S

Loading…

Class

FindCursor

A lazy, batched cursor over the results of a find.

Nothing is sent until the first read. Documents arrive in batches, and the cursor releases its server-side state when it is exhausted or closed. toArray() and for await close the cursor for you, even when the loop exits early or throws.

class FindCursor<TDocument extends object = Document, TResult extends object = WithId<TDocument>> implements AsyncIterable<TResult>

Defined in packages/driver/src/cursor.ts:143

Constructors#

Methods#

M

[asyncIterator]

#
[asyncIterator](): AsyncGenerator<TResult, void, undefined>

Iterates the remaining documents, closing the cursor when the loop ends.

Defined in packages/driver/src/cursor.ts:232

M

next

#
next(): Promise<TResult | null>

Returns the next document, or null when the results are exhausted or the cursor is closed.

Defined in packages/driver/src/cursor.ts:209

M

toArray

#
toArray(): Promise<TResult[]>

Reads all remaining documents into an array and closes the cursor. Large result sets are held in memory; iterate instead when they may be large.

Defined in packages/driver/src/cursor.ts:217

Used by#