Class Aggregate<ResultType>

Type Parameters

  • ResultType

Hierarchy

  • Aggregate

Implements

Constructors

  • Type Parameters

    • ResultType

    Returns Aggregate<ResultType>

Properties

[toStringTag]: string
catch: (<TResult>(onrejected?) => Promise<ResultType | TResult>)

Type declaration

    • <TResult>(onrejected?): Promise<ResultType | TResult>
    • Executes the query returning a Promise which will be resolved with either the doc(s) or rejected with the error. Like .then(), but only takes a rejection handler.

      Type Parameters

      • TResult = never

      Parameters

      • Optional onrejected: ((reason) => TResult | PromiseLike<TResult>)
        Optional
          • (reason): TResult | PromiseLike<TResult>
          • Parameters

            • reason: any

            Returns TResult | PromiseLike<TResult>

      Returns Promise<ResultType | TResult>

finally: ((onfinally?) => Promise<ResultType>)

Type declaration

    • (onfinally?): Promise<ResultType>
    • Executes the aggregation returning a Promise which will be resolved with .finally() chained.

      Parameters

      • Optional onfinally: (() => void)
        Optional
          • (): void
          • Returns void

      Returns Promise<ResultType>

then: (<TResult1, TResult2>(onfulfilled?, onrejected?) => Promise<TResult1 | TResult2>)

Type declaration

    • <TResult1, TResult2>(onfulfilled?, onrejected?): Promise<TResult1 | TResult2>
    • Provides promise for aggregate.

      Type Parameters

      • TResult1 = ResultType

      • TResult2 = never

      Parameters

      • Optional onfulfilled: ((value) => TResult1 | PromiseLike<TResult1>)
        Optional
          • (value): TResult1 | PromiseLike<TResult1>
          • Parameters

            • value: ResultType

            Returns TResult1 | PromiseLike<TResult1>

      • Optional onrejected: ((reason) => TResult2 | PromiseLike<TResult2>)
        Optional
          • (reason): TResult2 | PromiseLike<TResult2>
          • Parameters

            • reason: any

            Returns TResult2 | PromiseLike<TResult2>

      Returns Promise<TResult1 | TResult2>

Methods

  • Returns an asyncIterator for use with for/await/of loops You do not need to call this function explicitly, the JavaScript runtime will call it for you.

    Returns AsyncIterableIterator<Unpacked<ResultType>>

  • Sets an option on this aggregation. This function will be deprecated in a future release.

    Parameters

    Returns Aggregate<ResultType>

    Deprecated

  • Appends a new $addFields operator to this aggregate pipeline. Requires MongoDB v3.4+ to work

    Parameters

    • arg: Record<string, any>

    Returns Aggregate<ResultType>

  • Sets the allowDiskUse option for the aggregation query

    Parameters

    • value: boolean

    Returns Aggregate<ResultType>

  • Appends new operators to this aggregate pipeline

    Parameters

    Returns Aggregate<ResultType>

  • Set the collation.

    Parameters

    Returns Aggregate<ResultType>

  • Appends a new $count operator to this aggregate pipeline.

    Parameters

    • fieldName: string

    Returns Aggregate<ResultType>

  • Sets the cursor option for the aggregation query

    Type Parameters

    • DocType = any

    Parameters

    • Optional options: Record<string, unknown>
      Optional

    Returns Cursor<DocType, never>

  • Appends a new $densify operator to this aggregate pipeline

    Parameters

    • arg: {
          field: string;
          partitionByFields?: string[];
          range: {
              bounds: number[] | "partition" | Date[] | "full";
              step: number;
              unit?: "second" | "millisecond" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
          };
      }
      • field: string
      • Optional partitionByFields?: string[]
      • range: {
            bounds: number[] | "partition" | Date[] | "full";
            step: number;
            unit?: "second" | "millisecond" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
        }
        • bounds: number[] | "partition" | Date[] | "full"
        • step: number
        • Optional unit?: "second" | "millisecond" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year"

    Returns Aggregate<ResultType>

  • Executes the aggregate pipeline on the currently bound Model.

    Returns Promise<ResultType>

  • Execute the aggregation with explain

    Parameters

    Returns Promise<AnyObject>

  • Returns Promise<AnyObject>

  • Combines multiple aggregation pipelines.

    Parameters

    Returns Aggregate<ResultType>

  • Appends a new $fill operator to this aggregate pipeline

    Parameters

    • arg: {
          output: Record<string, {
              value: any;
          } | {
              method: "linear" | "locf";
          }>;
          partitionBy?: any;
          partitionByFields?: string[];
          sortBy?: Record<string, 1 | -1>;
      }
      • output: Record<string, {
            value: any;
        } | {
            method: "linear" | "locf";
        }>
      • Optional partitionBy?: any
      • Optional partitionByFields?: string[]
      • Optional sortBy?: Record<string, 1 | -1>

    Returns Aggregate<ResultType>

  • Appends new custom $graphLookup operator(s) to this aggregate pipeline, performing a recursive search on a collection.

    Parameters

    • options: {
          as: string;
          connectFromField: string;
          connectToField: string;
          depthField?: string;
          from: string;
          maxDepth?: number;
          restrictSearchWithMatch?: AnyObject;
          startWith: any;
      }
      • as: string
      • connectFromField: string
      • connectToField: string
      • Optional depthField?: string
      • from: string
      • Optional maxDepth?: number
      • Optional restrictSearchWithMatch?: AnyObject
      • startWith: any

    Returns Aggregate<ResultType>

  • Appends new custom $group operator to this aggregate pipeline.

    Parameters

    Returns Aggregate<ResultType>

  • Sets the hint option for the aggregation query

    Parameters

    • value: string | Record<string, unknown>

    Returns Aggregate<ResultType>

  • Appends a new $limit operator to this aggregate pipeline.

    Parameters

    • num: number

      maximum number of records to pass to the next stage

    Returns Aggregate<ResultType>

  • Appends a new custom $match operator to this aggregate pipeline.

    Parameters

    Returns Aggregate<ResultType>

  • Binds this aggregate to a model.

    Parameters

    • model: mongoose.Model<any, {}, {}, {}, any, any>

      the model to which the aggregate is to be bound

    Returns Aggregate<ResultType>

  • Returns the current model bound to this aggregate object

    Returns mongoose.Model<any, {}, {}, {}, any, any>

  • Appends a new $geoNear operator to this aggregate pipeline.

    Parameters

    • arg: {
          distanceField: string;
          distanceMultiplier?: number;
          includeLocs?: string;
          key?: string;
          maxDistance?: number;
          minDistance?: number;
          near: [number, number] | {
              coordinates: [number, number];
              type: "Point";
          };
          num?: number;
          query?: AnyObject;
          spherical?: boolean;
      }
      • distanceField: string
      • Optional distanceMultiplier?: number
      • Optional includeLocs?: string
      • Optional key?: string
      • Optional maxDistance?: number
      • Optional minDistance?: number
      • near: [number, number] | {
            coordinates: [number, number];
            type: "Point";
        }
      • Optional num?: number

        Deprecated. Use only with MondoDB below 4.2 (removed in 4.2)

        Deprecated

      • Optional query?: AnyObject
      • Optional spherical?: boolean

    Returns Aggregate<ResultType>

  • Lets you set arbitrary options, for middlewares or plugins.

    Parameters

    Returns Aggregate<ResultType>

  • Returns the current pipeline

    Returns PipelineStage[]

  • Sets the readPreference option for the aggregation query.

    Parameters

    Returns Aggregate<ResultType>

  • Sets the readConcern level for the aggregation query.

    Parameters

    • level: string

    Returns Aggregate<ResultType>

  • Appends a new $redact operator to this aggregate pipeline.

    Parameters

    • expression: any
    • thenExpr: AnyObject | "$$DESCEND" | "$$PRUNE" | "$$KEEP"
    • elseExpr: AnyObject | "$$DESCEND" | "$$PRUNE" | "$$KEEP"

    Returns Aggregate<ResultType>

  • Appends a new $replaceRoot operator to this aggregate pipeline.

    Parameters

    • newRoot: any

    Returns Aggregate<ResultType>

  • Appends new custom $sample operator to this aggregate pipeline.

    Parameters

    • arg: number

    Returns Aggregate<ResultType>

  • Helper for Atlas Text Search's $search stage.

    Parameters

    • options: {
          highlight?: {
              maxCharsToExamine?: number;
              maxNumPassages?: number;
              path: string | string[] | {
                  multi: string;
                  value: string;
              };
          };
          index?: string;
          [operator: string]: any;
      }
      • [operator: string]: any
      • Optional highlight?: {
            maxCharsToExamine?: number;
            maxNumPassages?: number;
            path: string | string[] | {
                multi: string;
                value: string;
            };
        }
        • Optional maxCharsToExamine?: number
        • Optional maxNumPassages?: number
        • path: string | string[] | {
              multi: string;
              value: string;
          }
      • Optional index?: string

    Returns Aggregate<ResultType>

  • Appends a new $skip operator to this aggregate pipeline.

    Parameters

    • num: number

      number of records to skip before next stage

    Returns Aggregate<ResultType>

  • Appends a new $sort operator to this aggregate pipeline.

    Parameters

    • arg: string | Record<string, SortOrder> | Record<string, 1 | -1 | Meta>

    Returns Aggregate<ResultType>

  • Appends a new $sortByCount operator to this aggregate pipeline. Accepts either a string field name or a pipeline object.

    Parameters

    • arg: any

    Returns Aggregate<ResultType>

  • Appends new custom $unwind operator(s) to this aggregate pipeline.

    Parameters

    • Rest ...args: (string | {
          includeArrayIndex?: string;
          path: string;
          preserveNullAndEmptyArrays?: boolean;
      })[]
      Rest

    Returns Aggregate<ResultType>

Generated using TypeDoc