Class
AggregateCursor
A lazy, batched cursor over the results of an aggregation. It reads like a
FindCursor: nothing is sent until the first read, documents arrive in
batches, and toArray() and for await close the cursor for you.
class AggregateCursor<TResult extends object = Document> implements AsyncIterable<TResult>Defined in packages/driver/src/cursor.ts:242
Constructors#
constructor
#new AggregateCursor<TResult extends object = Document>(
execute: CursorExecutor,
collection: string,
pipeline: readonly Document[],
batchSize: number | undefined,
budget?: QueryBudgetOptions,
)Defined in packages/driver/src/cursor.ts:247
Methods#
[asyncIterator]
#[asyncIterator](): AsyncGenerator<TResult, void, undefined>Iterates the remaining documents, closing the cursor when the loop ends.
Defined in packages/driver/src/cursor.ts:303
close
#close(): Promise<void>Closes the cursor and releases it on the server. Closing twice does nothing.
Defined in packages/driver/src/cursor.ts:296
hasNext
#hasNext(): Promise<boolean>Whether another document is available. This may fetch the next batch.
Defined in packages/driver/src/cursor.ts:272
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:280
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:288