Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Aggregate<ResultType>

Type Parameters

  • ResultType

Hierarchy

  • Aggregate

Implements

Index

Constructors

  • new Aggregate<ResultType>(): Aggregate<ResultType>
  • Type Parameters

    • ResultType

    Returns Aggregate<ResultType>

Methods

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

    deprecated

    Parameters

    Returns Aggregate<ResultType>

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

    Parameters

    Returns Aggregate<ResultType>

  • allowDiskUse(value: boolean): 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>

  • count(fieldName: string): Aggregate<ResultType>
  • Appends a new $count operator to this aggregate pipeline.

    Parameters

    • fieldName: string

    Returns Aggregate<ResultType>

  • densify(arg: { field: string; partitionByFields?: string[]; range: { step: number; unit?: "millisecond" | "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year"; bounds: number[] | Date[] | "full" | "partition" } }): Aggregate<ResultType>
  • Appends a new $densify operator to this aggregate pipeline

    Parameters

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

    Returns Aggregate<ResultType>

  • Sets the cursor option for the aggregation query

    Type Parameters

    • DocType = any

    Parameters

    Returns Cursor<DocType, never>

  • Executes the aggregate pipeline on the currently bound Model.

    Parameters

    Returns void

  • Returns Promise<ResultType>

  • fill(arg: { partitionBy?: any; partitionByFields?: string[]; sortBy?: <internal>.Record<string, 1 | -1>; output: <internal>.Record<string, { value: any } | { method: "linear" | "locf" }> }): Aggregate<ResultType>
  • Appends a new $fill operator to this aggregate pipeline

    Parameters

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

    Returns Aggregate<ResultType>

  • graphLookup(options: { from: string; startWith: any; connectFromField: string; connectToField: string; as: string; maxDepth?: number; depthField?: string; restrictSearchWithMatch?: AnyObject }): Aggregate<ResultType>
  • Appends new custom $graphLookup operator(s) to this aggregate pipeline, performing a recursive search on a collection.

    Parameters

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

    Returns Aggregate<ResultType>

  • group(arg: { _id: any } | {}): Aggregate<ResultType>
  • Appends new custom $group operator to this aggregate pipeline.

    Parameters

    • arg: { _id: any } | {}

    Returns Aggregate<ResultType>

  • Sets the hint option for the aggregation query

    Parameters

    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: <internal>.Model<any, {}, {}, {}, any>

      the model to which the aggregate is to be bound

    Returns Aggregate<ResultType>

  • near(arg: { near?: number[]; distanceField: string; maxDistance?: number; query?: <internal>.Record<string, any>; includeLocs?: string; num?: number; uniqueDocs?: boolean }): Aggregate<ResultType>
  • Append a new $near operator to this aggregation pipeline

    Parameters

    • arg: { near?: number[]; distanceField: string; maxDistance?: number; query?: <internal>.Record<string, any>; includeLocs?: string; num?: number; uniqueDocs?: boolean }

      $near operator contents

      • Optional near?: number[]
      • distanceField: string
      • Optional maxDistance?: number
      • Optional query?: <internal>.Record<string, any>
      • Optional includeLocs?: string
      • Optional num?: number
      • Optional uniqueDocs?: boolean

    Returns Aggregate<ResultType>

  • Returns the current pipeline

    Returns PipelineStage[]

  • Sets the readPreference option for the aggregation query.

    Parameters

    Returns Aggregate<ResultType>

  • readConcern(level: string): Aggregate<ResultType>
  • Sets the readConcern level for the aggregation query.

    Parameters

    • level: string

    Returns Aggregate<ResultType>

  • redact(expression: any, thenExpr: AnyObject | "$$DESCEND" | "$$PRUNE" | "$$KEEP", elseExpr: AnyObject | "$$DESCEND" | "$$PRUNE" | "$$KEEP"): 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>

  • replaceRoot(newRoot: any): Aggregate<ResultType>
  • Appends a new $replaceRoot operator to this aggregate pipeline.

    Parameters

    • newRoot: any

    Returns Aggregate<ResultType>

  • search(options: { index?: string; highlight?: { path: string | string[] | { value: string; multi: string }; maxCharsToExamine?: number; maxNumPassages?: number } }): Aggregate<ResultType>
  • Helper for Atlas Text Search's $search stage.

    Parameters

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

    Returns Aggregate<ResultType>

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

    Parameters

    Returns Aggregate<ResultType>

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

    Parameters

    • arg: number

    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 $sortByCount operator to this aggregate pipeline. Accepts either a string field name or a pipeline object.

    Parameters

    • arg: any

    Returns Aggregate<ResultType>

  • unwind(...args: (string | { path: string; includeArrayIndex?: string; preserveNullAndEmptyArrays?: boolean })[]): Aggregate<ResultType>
  • Appends new custom $unwind operator(s) to this aggregate pipeline.

    Parameters

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

    Returns Aggregate<ResultType>

Properties

catch: (<TResult>(onrejected?: ((reason: any) => TResult | <internal>.PromiseLike<TResult>)) => Promise<ResultType | TResult>)

Type declaration

    • <TResult>(onrejected?: ((reason: any) => TResult | <internal>.PromiseLike<TResult>)): Promise<ResultType | TResult>
    • Attaches a callback for only the rejection of the Promise.

      Type Parameters

      • TResult = never

      Parameters

      Returns Promise<ResultType | TResult>

      A Promise for the completion of the callback.

then: (<TResult1, TResult2>(onfulfilled?: ((value: ResultType) => TResult1 | <internal>.PromiseLike<TResult1>), onrejected?: ((reason: any) => TResult2 | <internal>.PromiseLike<TResult2>)) => Promise<TResult1 | TResult2>)

Type declaration

    • <TResult1, TResult2>(onfulfilled?: ((value: ResultType) => TResult1 | <internal>.PromiseLike<TResult1>), onrejected?: ((reason: any) => TResult2 | <internal>.PromiseLike<TResult2>)): Promise<TResult1 | TResult2>
    • Attaches callbacks for the resolution and/or rejection of the Promise.

      Type Parameters

      • TResult1 = ResultType

      • TResult2 = never

      Parameters

      Returns Promise<TResult1 | TResult2>

      A Promise for the completion of which ever callback is executed.

Generated using TypeDoc