# PipelineSource


```
public final class PipelineSource
```

<br />

*** ** * ** ***

Start of a Firestore Pipeline

## Summary

| ### Nested types |
|---|
| `public static class https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#collection(kotlin.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html path)` Set the pipeline's source to the collection specified by the given path. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#collection(com.google.firebase.firestore.CollectionReference)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference ref)` Set the pipeline's source to the collection specified by the given `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference`. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#collection(com.google.firebase.firestore.CollectionReference,com.google.firebase.firestore.pipeline.CollectionSourceOptions)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference ref, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/CollectionSourceOptions options )` Set the pipeline's source to the collection specified by the given `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference`. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#collectionGroup(kotlin.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html collectionId)` Set the pipeline's source to the collection group with the given id. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#collectionGroup(kotlin.String,com.google.firebase.firestore.pipeline.CollectionGroupOptions)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html collectionId, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/CollectionGroupOptions options )` Set the pipeline's source to the collection group with the given id. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#createFrom(com.google.firebase.firestore.AggregateQuery)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/AggregateQuery aggregateQuery)` Convert the given Aggregate Query into an equivalent Pipeline. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#createFrom(com.google.firebase.firestore.Query)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query query)` Convert the given Query into an equivalent Pipeline. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#database()()` Set the pipeline's source to be all documents in this database. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#documents(kotlin.Array)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference documents)` Set the pipeline's source to the documents specified by the given DocumentReferences. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#documents(kotlin.Array)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html documents)` Set the pipeline's source to the documents specified by the given paths. |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#literals(kotlin.Array)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/Map.html<@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html, https://developer.android.com/reference/kotlin/java/lang/Object.html> data)` Sets the pipeline's source to the given literal documents. |
| `static final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#subcollection(kotlin.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html path)` Initializes a pipeline scoped to a subcollection. |
| `static final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#subcollection(com.google.firebase.firestore.pipeline.SubcollectionSource)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/SubcollectionSource source)` Creates a pipeline that processes the documents in the specified subcollection of the current document. |

## Public methods

### collection

```
public final @NonNull Pipeline collection(@NonNull String path)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html path` | A path to a collection that will be the source of this pipeline. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object with documents from target collection. |

### collection

```
public final @NonNull Pipeline collection(@NonNull CollectionReference ref)
```

Set the pipeline's source to the collection specified by the given `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference ref` | A `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference` for a collection that will be the source of this pipeline. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object with documents from target collection. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html java.lang.IllegalArgumentException` | Thrown if the `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#collection(com.google.firebase.firestore.CollectionReference)` provided targets a different project or database than the pipeline. |

### collection

```
public final @NonNull Pipeline collection(
    @NonNull CollectionReference ref,
    @NonNull CollectionSourceOptions options
)
```

Set the pipeline's source to the collection specified by the given `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference ref` | A `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference` for a collection that will be the source of this pipeline. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/CollectionSourceOptions options` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/CollectionSourceOptions` for the collection. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object with documents from target collection. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html java.lang.IllegalArgumentException` | Thrown if the `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#collection(com.google.firebase.firestore.CollectionReference,com.google.firebase.firestore.pipeline.CollectionSourceOptions)` provided targets a different project or database than the pipeline. |

### collectionGroup

```
public final @NonNull Pipeline collectionGroup(@NonNull String collectionId)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html collectionId` | The id of a collection group that will be the source of this pipeline. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object with documents from target collection group. |

### collectionGroup

```
public final @NonNull Pipeline collectionGroup(
    @NonNull String collectionId,
    @NonNull CollectionGroupOptions options
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html collectionId` | The id of a collection group that will be the source of this pipeline. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/CollectionGroupOptions options` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/CollectionGroupOptions` for the collection group. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object with documents from target collection group. |

### createFrom

```
public final @NonNull Pipeline createFrom(@NonNull AggregateQuery aggregateQuery)
```

Convert the given Aggregate Query into an equivalent Pipeline.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/AggregateQuery aggregateQuery` | An Aggregate Query to be converted into a Pipeline. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object that is equivalent to `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#createFrom(com.google.firebase.firestore.AggregateQuery)` |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html java.lang.IllegalArgumentException` | Thrown if the `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#createFrom(com.google.firebase.firestore.AggregateQuery)` provided targets a different project or database than the pipeline. |

### createFrom

```
public final @NonNull Pipeline createFrom(@NonNull Query query)
```

Convert the given Query into an equivalent Pipeline.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query query` | A Query to be converted into a Pipeline. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object that is equivalent to `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#createFrom(com.google.firebase.firestore.Query)` |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html java.lang.IllegalArgumentException` | Thrown if the `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#createFrom(com.google.firebase.firestore.Query)` provided targets a different project or database than the pipeline. |

### database

```
public final @NonNull Pipeline database()
```

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object with all documents in this database. |

### documents

```
public final @NonNull Pipeline documents(@NonNull DocumentReference documents)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference documents` | DocumentReferences specifying the individual documents that will be the source of this pipeline. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | Pipeline with `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#documents(kotlin.Array)`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html java.lang.IllegalArgumentException` | Thrown if the `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#documents(kotlin.Array)` provided targets a different project or database than the pipeline. |

### documents

```
public final @NonNull Pipeline documents(@NonNull String documents)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html documents` | Paths specifying the individual documents that will be the source of this pipeline. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object with `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/PipelineSource#documents(kotlin.Array)`. |

### literals

```
public final @NonNull Pipeline literals(@NonNull Map<@NonNull String, Object> data)
```

Sets the pipeline's source to the given literal documents. Each map becomes one input document.

Field values can be constants or `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/Expression`s; expressions are evaluated, including expressions nested inside map or list values. FieldValue sentinels (for example, `FieldValue.serverTimestamp()`) are not supported; use an expression such as `currentTimestamp()` instead.

To give a document a path, for example to write it with `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline#upsert(kotlin.Array)`, set its `__name__` field to a `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference`.

Example:

```
db.pipeline()
  .literals(mapOf("title" to "Dune"), mapOf("title" to "Emma"))
  .insert("books")
  .execute()
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/Map.html<@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html, https://developer.android.com/reference/kotlin/java/lang/Object.html> data` | The documents to use as the source. At least one document is required; a pipeline without literal documents fails when it is executed. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` object with the literal documents as its source. |

### subcollection

```
public static final @NonNull Pipeline subcollection(@NonNull String path)
```

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 |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html path` | The path of the subcollection. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` instance scoped to the subcollection. |

### subcollection

```
public static final @NonNull Pipeline subcollection(@NonNull SubcollectionSource source)
```

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 |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/pipeline/SubcollectionSource source` | The subcollection that will be the source of this pipeline. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` | A new `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Pipeline` scoped to the subcollection. |