PipelineSource

class PipelineSource


Start of a Firestore Pipeline

Summary

Public companion functions

Pipeline

Initializes a pipeline scoped to a subcollection.

Pipeline

Creates a pipeline that processes the documents in the specified subcollection of the current document.

Public functions

Pipeline

Set the pipeline's source to the collection specified by the given path.

Pipeline

Set the pipeline's source to the collection specified by the given CollectionReference.

Pipeline

Set the pipeline's source to the collection specified by the given CollectionReference.

Pipeline
collectionGroup(collectionId: String)

Set the pipeline's source to the collection group with the given id.

Pipeline
collectionGroup(collectionId: String, options: CollectionGroupOptions)

Set the pipeline's source to the collection group with the given id.

Pipeline
createFrom(aggregateQuery: AggregateQuery)

Convert the given Aggregate Query into an equivalent Pipeline.

Pipeline
createFrom(query: Query)

Convert the given Query into an equivalent Pipeline.

Pipeline

Set the pipeline's source to be all documents in this database.

Pipeline
documents(vararg documents: DocumentReference)

Set the pipeline's source to the documents specified by the given DocumentReferences.

Pipeline
documents(vararg documents: String)

Set the pipeline's source to the documents specified by the given paths.

Public companion functions

subcollection

fun subcollection(path: String): Pipeline

Initializes a pipeline scoped to a subcollection.

This method allows you to start a new pipeline that operates on a subcollection of the current document. It is intended to be used as a subquery.

Note: A pipeline created with subcollection cannot be executed directly. It must be used within a parent pipeline.

Example:

firestore.pipeline().collection("books")
.addFields(
PipelineSource.subcollection("reviews")
.aggregate(AggregateFunction.average("rating").as("avg_rating"))
.toScalarExpression().as("average_rating"))
Parameters
path: String

The path of the subcollection.

Returns
Pipeline

A new Pipeline instance scoped to the subcollection.

subcollection

fun subcollection(source: SubcollectionSource): Pipeline

Creates a pipeline that processes the documents in the specified subcollection of the current document.

Example:

firestore.pipeline().collection("books")
.addFields(
PipelineSource.subcollection(SubcollectionSource.of("reviews"))
.aggregate(AggregateFunction.average("rating").as("avg_rating"))
.toScalarExpression().as("average_rating"))
Parameters
source: SubcollectionSource

The subcollection that will be the source of this pipeline.

Returns
Pipeline

A new Pipeline scoped to the subcollection.

Public functions

collection

fun collection(path: String): Pipeline

Set the pipeline's source to the collection specified by the given path.

Parameters
path: String

A path to a collection that will be the source of this pipeline.

Returns
Pipeline

A new Pipeline object with documents from target collection.

collection

fun collection(ref: CollectionReference): Pipeline

Set the pipeline's source to the collection specified by the given CollectionReference.

Parameters
ref: CollectionReference

A CollectionReference for a collection that will be the source of this pipeline.

Returns
Pipeline

A new Pipeline object with documents from target collection.

Throws
kotlin.IllegalArgumentException: kotlin.IllegalArgumentException

Thrown if the ref provided targets a different project or database than the pipeline.

collection

fun collection(ref: CollectionReference, options: CollectionSourceOptions): Pipeline

Set the pipeline's source to the collection specified by the given CollectionReference.

Parameters
ref: CollectionReference

A CollectionReference for a collection that will be the source of this pipeline.

options: CollectionSourceOptions

CollectionSourceOptions for the collection.

Returns
Pipeline

A new Pipeline object with documents from target collection.

Throws
kotlin.IllegalArgumentException: kotlin.IllegalArgumentException

Thrown if the ref provided targets a different project or database than the pipeline.

collectionGroup

fun collectionGroup(collectionId: String): Pipeline

Set the pipeline's source to the collection group with the given id.

Parameters
collectionId: String

The id of a collection group that will be the source of this pipeline.

Returns
Pipeline

A new Pipeline object with documents from target collection group.

collectionGroup

fun collectionGroup(collectionId: String, options: CollectionGroupOptions): Pipeline

Set the pipeline's source to the collection group with the given id.

Parameters
collectionId: String

The id of a collection group that will be the source of this pipeline.

options: CollectionGroupOptions

CollectionGroupOptions for the collection group.

Returns
Pipeline

A new Pipeline object with documents from target collection group.

createFrom

fun createFrom(aggregateQuery: AggregateQuery): Pipeline

Convert the given Aggregate Query into an equivalent Pipeline.

Parameters
aggregateQuery: AggregateQuery

An Aggregate Query to be converted into a Pipeline.

Returns
Pipeline

A new Pipeline object that is equivalent to aggregateQuery

Throws
kotlin.IllegalArgumentException: kotlin.IllegalArgumentException

Thrown if the aggregateQuery provided targets a different project or database than the pipeline.

createFrom

fun createFrom(query: Query): Pipeline

Convert the given Query into an equivalent Pipeline.

Parameters
query: Query

A Query to be converted into a Pipeline.

Returns
Pipeline

A new Pipeline object that is equivalent to query

Throws
kotlin.IllegalArgumentException: kotlin.IllegalArgumentException

Thrown if the query provided targets a different project or database than the pipeline.

database

fun database(): Pipeline

Set the pipeline's source to be all documents in this database.

Returns
Pipeline

A new Pipeline object with all documents in this database.

documents

fun documents(vararg documents: DocumentReference): Pipeline

Set the pipeline's source to the documents specified by the given DocumentReferences.

Parameters
vararg documents: DocumentReference

DocumentReferences specifying the individual documents that will be the source of this pipeline.

Returns
Pipeline

Pipeline with documents.

Throws
kotlin.IllegalArgumentException: kotlin.IllegalArgumentException

Thrown if the documents provided targets a different project or database than the pipeline.

documents

fun documents(vararg documents: String): Pipeline

Set the pipeline's source to the documents specified by the given paths.

Parameters
vararg documents: String

Paths specifying the individual documents that will be the source of this pipeline.

Returns
Pipeline

A new Pipeline object with documents.