import type { Document } from '../bson'; import type { ExplainVerbosityLike } from '../explain'; import type { MongoClient } from '../mongo_client'; import { AggregateOptions } from '../operations/aggregate'; import { ExecutionResult } from '../operations/execute_operation'; import type { ClientSession } from '../sessions'; import type { Sort } from '../sort'; import type { Callback, MongoDBNamespace } from '../utils'; import type { AbstractCursorOptions } from './abstract_cursor'; import { AbstractCursor } from './abstract_cursor'; /** @public */ export interface AggregationCursorOptions extends AbstractCursorOptions, AggregateOptions { } /** @internal */ declare const kPipeline: unique symbol; /** @internal */ declare const kOptions: unique symbol; /** * The **AggregationCursor** class is an internal class that embodies an aggregation cursor on MongoDB * allowing for iteration over the results returned from the underlying query. It supports * one by one document iteration, conversion to an array or can be iterated as a Node 4.X * or higher stream * @public */ export declare class AggregationCursor extends AbstractCursor { /** @internal */ [kPipeline]: Document[]; /** @internal */ [kOptions]: AggregateOptions; /** @internal */ constructor(client: MongoClient, namespace: MongoDBNamespace, pipeline?: Document[], options?: AggregateOptions); get pipeline(): Document[]; clone(): AggregationCursor; map(transform: (doc: TSchema) => T): AggregationCursor; /** @internal */ _initialize(session: ClientSession, callback: Callback): void; /** Execute the explain for the cursor */ explain(): Promise; explain(callback: Callback): void; explain(verbosity: ExplainVerbosityLike): Promise; /** Add a group stage to the aggregation pipeline */ group($group: Document): AggregationCursor; /** Add a limit stage to the aggregation pipeline */ limit($limit: number): this; /** Add a match stage to the aggregation pipeline */ match($match: Document): this; /** Add an out stage to the aggregation pipeline */ out($out: { db: string; coll: string; } | string): this; /** * Add a project stage to the aggregation pipeline * * @remarks * In order to strictly type this function you must provide an interface * that represents the effect of your projection on the result documents. * * By default chaining a projection to your cursor changes the returned type to the generic {@link Document} type. * You should specify a parameterized type to have assertions on your final results. * * @example * ```typescript * // Best way * const docs: AggregationCursor<{ a: number }> = cursor.project<{ a: number }>({ _id: 0, a: true }); * // Flexible way * const docs: AggregationCursor = cursor.project({ _id: 0, a: true }); * ``` * * @remarks * In order to strictly type this function you must provide an interface * that represents the effect of your projection on the result documents. * * **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor, * it **does not** return a new instance of a cursor. This means when calling project, * you should always assign the result to a new variable in order to get a correctly typed cursor variable. * Take note of the following example: * * @example * ```typescript * const cursor: AggregationCursor<{ a: number; b: string }> = coll.aggregate([]); * const projectCursor = cursor.project<{ a: number }>({ _id: 0, a: true }); * const aPropOnlyArray: {a: number}[] = await projectCursor.toArray(); * * // or always use chaining and save the final cursor * * const cursor = coll.aggregate().project<{ a: string }>({ * _id: 0, * a: { $convert: { input: '$a', to: 'string' } * }}); * ``` */ project($project: Document): AggregationCursor; /** Add a lookup stage to the aggregation pipeline */ lookup($lookup: Document): this; /** Add a redact stage to the aggregation pipeline */ redact($redact: Document): this; /** Add a skip stage to the aggregation pipeline */ skip($skip: number): this; /** Add a sort stage to the aggregation pipeline */ sort($sort: Sort): this; /** Add a unwind stage to the aggregation pipeline */ unwind($unwind: Document | string): this; /** @deprecated Add a geoNear stage to the aggregation pipeline */ geoNear($geoNear: Document): this; } export {}; //# sourceMappingURL=aggregation_cursor.d.ts.map