Pipeline class

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

exportdeclareclassPipeline

Methods

MethodModifiersDescription
addFields(field, additionalFields)(Public Preview)
addFields(options)(Public Preview)
aggregate(accumulator, additionalAccumulators)(Public Preview)
aggregate(options)(Public Preview)
distinct(group, additionalGroups)(Public Preview)
distinct(options)(Public Preview)
findNearest(options)(Public Preview)
limit(limit)(Public Preview)
limit(options)(Public Preview)
offset(offset)(Public Preview)
offset(options)(Public Preview)
rawStage(name, params, options)(Public Preview)
removeFields(fieldValue, additionalFields)(Public Preview)
removeFields(options)(Public Preview)
replaceWith(fieldName)(Public Preview)
replaceWith(expr)(Public Preview)
replaceWith(options)(Public Preview)
sample(documents)(Public Preview)
sample(options)(Public Preview)
select(selection, additionalSelections)(Public Preview)
select(options)(Public Preview)
sort(ordering, additionalOrderings)(Public Preview)
sort(options)(Public Preview)
union(other)(Public Preview)
union(options)(Public Preview)
unnest(selectable, indexField)(Public Preview)
unnest(options)(Public Preview)
where(condition)(Public Preview)
where(options)(Public Preview)

Pipeline.addFields()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

addFields(field:Selectable,...additionalFields:Selectable[]):Pipeline;

Parameters

ParameterTypeDescription
fieldSelectable
additionalFieldsSelectable[]

Returns:

Pipeline

Pipeline.addFields()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

addFields(options:AddFieldsStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsAddFieldsStageOptions

Returns:

Pipeline

Pipeline.aggregate()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

aggregate(accumulator:AliasedAggregate,...additionalAccumulators:AliasedAggregate[]):Pipeline;

Parameters

ParameterTypeDescription
accumulatorAliasedAggregate
additionalAccumulatorsAliasedAggregate[]

Returns:

Pipeline

Pipeline.aggregate()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

aggregate(options:AggregateStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsAggregateStageOptions

Returns:

Pipeline

Pipeline.distinct()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

distinct(group:string|Selectable,...additionalGroups:Array<string|Selectable>):Pipeline;

Parameters

ParameterTypeDescription
groupstring |Selectable
additionalGroupsArray<string |Selectable>

Returns:

Pipeline

Pipeline.distinct()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

distinct(options:DistinctStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsDistinctStageOptions

Returns:

Pipeline

Pipeline.findNearest()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

findNearest(options:FindNearestStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsFindNearestStageOptions

Returns:

Pipeline

Pipeline.limit()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

limit(limit:number):Pipeline;

Parameters

ParameterTypeDescription
limitnumber

Returns:

Pipeline

Pipeline.limit()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

limit(options:LimitStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsLimitStageOptions

Returns:

Pipeline

Pipeline.offset()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

offset(offset:number):Pipeline;

Parameters

ParameterTypeDescription
offsetnumber

Returns:

Pipeline

Pipeline.offset()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

offset(options:OffsetStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsOffsetStageOptions

Returns:

Pipeline

Pipeline.rawStage()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

rawStage(name:string,params:unknown[],options?:{[key:string]:Expression|unknown;}):Pipeline;

Parameters

ParameterTypeDescription
namestring
paramsunknown[]
options{ [key: string]:Expression | unknown; }

Returns:

Pipeline

Pipeline.removeFields()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

removeFields(fieldValue:Field|string,...additionalFields:Array<Field|string>):Pipeline;

Parameters

ParameterTypeDescription
fieldValueField | string
additionalFieldsArray<Field | string>

Returns:

Pipeline

Pipeline.removeFields()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

removeFields(options:RemoveFieldsStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsRemoveFieldsStageOptions

Returns:

Pipeline

Pipeline.replaceWith()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

replaceWith(fieldName:string):Pipeline;

Parameters

ParameterTypeDescription
fieldNamestring

Returns:

Pipeline

Pipeline.replaceWith()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

replaceWith(expr:Expression):Pipeline;

Parameters

ParameterTypeDescription
exprExpression

Returns:

Pipeline

Pipeline.replaceWith()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

replaceWith(options:ReplaceWithStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsReplaceWithStageOptions

Returns:

Pipeline

Pipeline.sample()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

sample(documents:number):Pipeline;

Parameters

ParameterTypeDescription
documentsnumber

Returns:

Pipeline

Pipeline.sample()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

sample(options:SampleStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsSampleStageOptions

Returns:

Pipeline

Pipeline.select()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

select(selection:Selectable|string,...additionalSelections:Array<Selectable|string>):Pipeline;

Parameters

ParameterTypeDescription
selectionSelectable | string
additionalSelectionsArray<Selectable | string>

Returns:

Pipeline

Pipeline.select()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

select(options:SelectStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsSelectStageOptions

Returns:

Pipeline

Pipeline.sort()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

sort(ordering:Ordering,...additionalOrderings:Ordering[]):Pipeline;

Parameters

ParameterTypeDescription
orderingOrdering
additionalOrderingsOrdering[]

Returns:

Pipeline

Pipeline.sort()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

sort(options:SortStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsSortStageOptions

Returns:

Pipeline

Pipeline.union()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

union(other:Pipeline):Pipeline;

Parameters

ParameterTypeDescription
otherPipeline

Returns:

Pipeline

Pipeline.union()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

union(options:UnionStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsUnionStageOptions

Returns:

Pipeline

Pipeline.unnest()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

unnest(selectable:Selectable,indexField?:string):Pipeline;

Parameters

ParameterTypeDescription
selectableSelectable
indexFieldstring

Returns:

Pipeline

Pipeline.unnest()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

unnest(options:UnnestStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsUnnestStageOptions

Returns:

Pipeline

Pipeline.where()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

where(condition:BooleanExpression):Pipeline;

Parameters

ParameterTypeDescription
conditionBooleanExpression

Returns:

Pipeline

Pipeline.where()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

where(options:WhereStageOptions):Pipeline;

Parameters

ParameterTypeDescription
optionsWhereStageOptions

Returns:

Pipeline

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-01-15 UTC.