Pipeline class
A pipeline for querying and transforming Firestore data.
A Pipeline is composed of a sequence of stages. Each stage processes the output from the previous one, and the final stage's output is the result of the pipeline's execution.
Start with FirebaseFirestore.pipeline and a source stage (e.g. PipelineSource.collection), then add transformation and filtering stages. Call execute to run the pipeline.
Example:
final snapshot = await FirebaseFirestore.instance
.pipeline()
.collection('users')
.where(Expression.field('active').equal(true))
.limit(10)
.execute();
for (final result in snapshot.result) {
print(result.data());
}
Note on execution: The stages are conceptual. The Firestore backend may optimize execution (e.g., reordering or merging stages) as long as the final result remains the same.
Important limitations: Pipelines operate on a request/response basis only. They do not utilize or update the local SDK cache, and they do not support realtime snapshot listeners.
Properties
Methods
-
addFields(
Selectable selectable1, [Selectable? selectable2, Selectable? selectable3, Selectable? selectable4, Selectable? selectable5, Selectable? selectable6, Selectable? selectable7, Selectable? selectable8, Selectable? selectable9, Selectable? selectable10, Selectable? selectable11, Selectable? selectable12, Selectable? selectable13, Selectable? selectable14, Selectable? selectable15, Selectable? selectable16, Selectable? selectable17, Selectable? selectable18, Selectable? selectable19, Selectable? selectable20, Selectable? selectable21, Selectable? selectable22, Selectable? selectable23, Selectable? selectable24, Selectable? selectable25, Selectable? selectable26, Selectable? selectable27, Selectable? selectable28, Selectable? selectable29, Selectable? selectable30]) → Pipeline - Adds new fields to outputs from previous stages.
-
aggregate(
AliasedAggregateFunction aggregateFunction1, [AliasedAggregateFunction? aggregateFunction2, AliasedAggregateFunction? aggregateFunction3, AliasedAggregateFunction? aggregateFunction4, AliasedAggregateFunction? aggregateFunction5, AliasedAggregateFunction? aggregateFunction6, AliasedAggregateFunction? aggregateFunction7, AliasedAggregateFunction? aggregateFunction8, AliasedAggregateFunction? aggregateFunction9, AliasedAggregateFunction? aggregateFunction10, AliasedAggregateFunction? aggregateFunction11, AliasedAggregateFunction? aggregateFunction12, AliasedAggregateFunction? aggregateFunction13, AliasedAggregateFunction? aggregateFunction14, AliasedAggregateFunction? aggregateFunction15, AliasedAggregateFunction? aggregateFunction16, AliasedAggregateFunction? aggregateFunction17, AliasedAggregateFunction? aggregateFunction18, AliasedAggregateFunction? aggregateFunction19, AliasedAggregateFunction? aggregateFunction20, AliasedAggregateFunction? aggregateFunction21, AliasedAggregateFunction? aggregateFunction22, AliasedAggregateFunction? aggregateFunction23, AliasedAggregateFunction? aggregateFunction24, AliasedAggregateFunction? aggregateFunction25, AliasedAggregateFunction? aggregateFunction26, AliasedAggregateFunction? aggregateFunction27, AliasedAggregateFunction? aggregateFunction28, AliasedAggregateFunction? aggregateFunction29, AliasedAggregateFunction? aggregateFunction30]) → Pipeline - Performs aggregation operations on the documents from previous stages.
-
aggregateWithOptions(
AggregateStageOptions aggregateStage, {AggregateOptions? options}) → Pipeline - Performs optionally grouped aggregation operations on the documents from previous stages.
-
distinct(
Selectable expression1, [Selectable? expression2, Selectable? expression3, Selectable? expression4, Selectable? expression5, Selectable? expression6, Selectable? expression7, Selectable? expression8, Selectable? expression9, Selectable? expression10, Selectable? expression11, Selectable? expression12, Selectable? expression13, Selectable? expression14, Selectable? expression15, Selectable? expression16, Selectable? expression17, Selectable? expression18, Selectable? expression19, Selectable? expression20, Selectable? expression21, Selectable? expression22, Selectable? expression23, Selectable? expression24, Selectable? expression25, Selectable? expression26, Selectable? expression27, Selectable? expression28, Selectable? expression29, Selectable? expression30]) → Pipeline - Returns a set of distinct values from the inputs to this stage.
-
execute(
{ExecuteOptions? options}) → Future< PipelineSnapshot> - Executes this pipeline and returns the results as a PipelineSnapshot.
-
findNearest(
Field vectorField, List< double> vectorValue, DistanceMeasure distanceMeasure, {int? limit, String? distanceField}) → Pipeline - Performs a vector similarity search.
-
limit(
int limit) → Pipeline -
Limits the maximum number of documents returned by previous stages to
limit. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
offset(
int offset) → Pipeline -
Skips the first
offsetdocuments from the results of previous stages. -
removeFields(
String fieldPath1, [String? fieldPath2, String? fieldPath3, String? fieldPath4, String? fieldPath5, String? fieldPath6, String? fieldPath7, String? fieldPath8, String? fieldPath9, String? fieldPath10, String? fieldPath11, String? fieldPath12, String? fieldPath13, String? fieldPath14, String? fieldPath15, String? fieldPath16, String? fieldPath17, String? fieldPath18, String? fieldPath19, String? fieldPath20, String? fieldPath21, String? fieldPath22, String? fieldPath23, String? fieldPath24, String? fieldPath25, String? fieldPath26, String? fieldPath27, String? fieldPath28, String? fieldPath29, String? fieldPath30]) → Pipeline - Removes fields from outputs of previous stages.
-
replaceWith(
Expression expression) → Pipeline - Fully overwrites each document with the value of the given expression.
-
sample(
PipelineSample sample) → Pipeline - Performs a pseudo-random sampling of the input documents.
-
search(
SearchStage searchStage) → Pipeline - Adds a search stage to this pipeline.
-
select(
Selectable expression1, [Selectable? expression2, Selectable? expression3, Selectable? expression4, Selectable? expression5, Selectable? expression6, Selectable? expression7, Selectable? expression8, Selectable? expression9, Selectable? expression10, Selectable? expression11, Selectable? expression12, Selectable? expression13, Selectable? expression14, Selectable? expression15, Selectable? expression16, Selectable? expression17, Selectable? expression18, Selectable? expression19, Selectable? expression20, Selectable? expression21, Selectable? expression22, Selectable? expression23, Selectable? expression24, Selectable? expression25, Selectable? expression26, Selectable? expression27, Selectable? expression28, Selectable? expression29, Selectable? expression30]) → Pipeline - Selects or creates a set of fields from the outputs of previous stages.
-
sort(
Ordering order, [Ordering? order2, Ordering? order3, Ordering? order4, Ordering? order5, Ordering? order6, Ordering? order7, Ordering? order8, Ordering? order9, Ordering? order10, Ordering? order11, Ordering? order12, Ordering? order13, Ordering? order14, Ordering? order15, Ordering? order16, Ordering? order17, Ordering? order18, Ordering? order19, Ordering? order20, Ordering? order21, Ordering? order22, Ordering? order23, Ordering? order24, Ordering? order25, Ordering? order26, Ordering? order27, Ordering? order28, Ordering? order29, Ordering? order30]) → Pipeline - Sorts the documents from previous stages based on one or more orderings.
-
toString(
) → String -
A string representation of this object.
inherited
-
union(
Pipeline pipeline) → Pipeline -
Performs a union of all documents from this pipeline and
pipeline, including duplicates. -
unnest(
Selectable expression, [String? indexField]) → Pipeline - Takes a specified array from the input documents and outputs a document for each element, with the element stored in a field named by the alias.
-
where(
BooleanExpression expression) → Pipeline - Filters the documents from previous stages to only include those matching the specified BooleanExpression.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited