> Documentation index: https://firebase.google.com/docs/reference/llms.txt

# com.google.firebase.firestore

## Interfaces

|---|---|
| `EventListener` | An interface for event listeners. |
| `ListenerRegistration` | Represents a listener that can be removed by calling `remove`. |
| `LocalCacheSettings` | Marker interface implemented by all supported cache settings. |
| `MemoryGarbageCollectorSettings` |   |
| `OnProgressListener` | A listener that is called periodically during execution of a `LoadBundleTask`. |
| `Transaction.Function` | An interface for providing code to be executed within a transaction context. |
| `WriteBatch.Function` | An interface for providing code to be executed within a `WriteBatch` context. |

## Classes

|---|---|
| `AggregateField` | Represents an aggregation that can be performed by Firestore. |
| `AggregateField.AverageAggregateField` | Represents an "average" aggregation that can be performed by Firestore. |
| `AggregateField.CountAggregateField` | Represents a "count" aggregation that can be performed by Firestore. |
| `AggregateField.SumAggregateField` | Represents a "sum" aggregation that can be performed by Firestore. |
| `AggregateQuery` | A query that calculates aggregations over an underlying query. |
| `AggregateQuerySnapshot` | The results of executing an `AggregateQuery`. |
| `Blob` | Immutable class representing an array of bytes in Cloud Firestore. |
| `BsonObjectId` | Represents a BSON `ObjectId` type in Firestore documents. |
| `BsonTimestamp` | Represents a BSON Timestamp type in Firestore documents. |
| `CollectionReference` | A `CollectionReference` can be used for adding documents, getting document references, and querying for documents (using the methods inherited from `Query`). |
| `Decimal128Value` | Represents a 128-bit decimal type in Firestore documents. |
| `DocumentChange` | A `DocumentChange` represents a change to the documents matching a query. |
| `DocumentReference` | A `DocumentReference` refers to a document location in a Cloud Firestore database and can be used to write, read, or listen to the location. |
| `DocumentSnapshot` | A `DocumentSnapshot` contains data read from a document in your Cloud Firestore database. |
| `FieldPath` | A `FieldPath` refers to a field in a document. |
| `FieldValue` | Sentinel values that can be used when writing document fields with `set()` or ` update()`. |
| `Filter` | A `Filter` represents a restriction on one or more field values and can be used to refine the results of a `Query`. |
| `FirebaseFirestore` | Represents a Cloud Firestore database and is the entry point for all Cloud Firestore operations. |
| `FirebaseFirestoreSettings` | Settings used to configure a `FirebaseFirestore` instance. |
| `FirebaseFirestoreSettings.Builder` | A Builder for creating `FirebaseFirestoreSettings`. |
| `GeoPoint` | Immutable class representing a `GeoPoint` in Cloud Firestore |
| `Int32Value` | Represents a 32-bit integer type in Firestore documents. |
| `LoadBundleTask` | Represents the task of loading a Firestore bundle. |
| `LoadBundleTaskProgress` | Represents a progress update or a final state from loading bundles. |
| `MaxKey` | Represents the Firestore "Max Key" data type. |
| `MemoryCacheSettings` | Configures the SDK to use a memory cache. |
| `MemoryCacheSettings.Builder` | A Builder for creating `MemoryCacheSettings` instance. |
| `MemoryEagerGcSettings` | Configures the SDK to use an eager garbage collector for memory cache. |
| `MemoryEagerGcSettings.Builder` |   |
| `MemoryLruGcSettings` | Configures the SDK to use a Least-Recently-Used garbage collector for memory cache. |
| `MemoryLruGcSettings.Builder` |   |
| `MinKey` | Represents the Firestore "Min Key" data type. |
| `PersistentCacheIndexManager` | Persistent cache indexes can improve performance of local query execution. |
| `PersistentCacheSettings` | Configures the SDK to use a persistent cache. |
| `PersistentCacheSettings.Builder` | A Builder for creating `PersistentCacheSettings` instance. |
| `Pipeline` | A `Pipeline` is composed of a sequence of stages. |
| `Pipeline.ExecuteOptions` |   |
| `Pipeline.ExecuteOptions.IndexMode` |   |
| `Pipeline.Snapshot` | A `Snapshot` contains the results of a pipeline execution. |
| `PipelineResult` | Represents the results of a Pipeline query, including the data and metadata. |
| `PipelineSource` | Start of a Firestore Pipeline |
| `Query` | A `Query` which you can read or listen to. |
| `QueryDocumentSnapshot` | A `QueryDocumentSnapshot` contains data read from a document in your Cloud Firestore database as part of a query. |
| `QuerySnapshot` | A `QuerySnapshot` contains the results of a query. |
| `RegexValue` | Represents a regular expression type in Firestore documents. |
| `SetOptions` | An options object that configures the behavior of `set()` calls. |
| `SnapshotListenOptions` | An options object that configures the behavior of `addSnapshotListener()` calls. |
| `SnapshotListenOptions.Builder` | Builder for constructing `SnapshotListenOptions` instances. |
| `SnapshotMetadata` | Metadata about a snapshot, describing the state of the snapshot. |
| `Transaction` | A `Transaction` is passed to a Function to provide the methods to read and write data within the transaction context. |
| `TransactionOptions` | Options to customize transaction behavior for `runTransaction`. |
| `TransactionOptions.Builder` | A Builder for creating `TransactionOptions`. |
| `VectorValue` | Represent a vector type in Firestore documents. |
| `WriteBatch` | A write batch, used to perform multiple writes as a single atomic unit. |

## Exceptions

|---|---|
| `FirebaseFirestoreException` | A class of exceptions thrown by Cloud Firestore. |

## Annotations

|---|---|
| `DocumentId` | Annotation used to mark a POJO property to be automatically populated with the document's ID when the POJO is created from a Cloud Firestore document (for example, via `toObject`). |
| `Exclude` | Marks a field as excluded from the database instance. |
| `IgnoreExtraProperties` | Properties that don't map to class fields are ignored when serializing to a class annotated with this annotation. |
| `PropertyName` | Marks a field to be renamed when serialized. |
| `ServerTimestamp` | Annotation used to mark a timestamp field to be populated with a server timestamp. |
| `ThrowOnExtraProperties` | Properties that don't map to class fields when serializing to a class annotated with this annotation cause an exception to be thrown. |

## Enums

|---|---|
| `AggregateSource` | The sources from which an `AggregateQuery` can retrieve its results. |
| `DocumentChange.Type` | An enumeration of snapshot diff types. |
| `DocumentSnapshot.ServerTimestampBehavior` | Controls the return value for server timestamps that have not yet been set to their final value. |
| `FirebaseFirestoreException.Code` | The set of Cloud Firestore status codes. |
| `ListenSource` | Configures the source option of `addSnapshotListener()` calls on `DocumentReference` and `Query`. |
| `LoadBundleTaskProgress.TaskState` | Represents the state of bundle loading tasks. |
| `MetadataChanges` | Indicates whether metadata-only changes (that is, only `DocumentSnapshot.getMetadata()` or `QuerySnapshot.getMetadata()` changed) should trigger snapshot events. |
| `Query.Direction` | An enum for the direction of a sort. |
| `Source` | Configures the behavior of `get()` calls on `DocumentReference` and `Query`. |

## Top-level functions summary

|---|---|
| `FirebaseFirestoreSettings` | `firestoreSettings(init: FirebaseFirestoreSettings.Builder.() -> Unit)` Returns a `FirebaseFirestoreSettings` instance initialized using the `init` function. |
| `MemoryCacheSettings` | `memoryCacheSettings(init: MemoryCacheSettings.Builder.() -> Unit)` |
| `MemoryEagerGcSettings` | `memoryEagerGcSettings(init: MemoryEagerGcSettings.Builder.() -> Unit)` |
| `MemoryLruGcSettings` | `memoryLruGcSettings(init: MemoryLruGcSettings.Builder.() -> Unit)` |
| `PersistentCacheSettings` | `persistentCacheSettings(init: PersistentCacheSettings.Builder.() -> Unit)` |

## Extension functions summary

|---|---|
| `inline Flow<T?>` | `<T : Any> DocumentReference.dataObjects(metadataChanges: MetadataChanges)` Starts listening to the document referenced by this `DocumentReference` with the given options and emits its values converted to a POJO via a `Flow`. |
| `inline Flow<List<T>>` | `<T : Any> Query.dataObjects(metadataChanges: MetadataChanges)` Starts listening to this query with the given options and emits its values converted to a POJO via a `Flow`. |
| `FirebaseFirestore` | `Firebase.firestore(app: FirebaseApp, database: String)` Returns the `FirebaseFirestore` instance of a given `FirebaseApp` and database name. |
| `FirebaseFirestore` | `Firebase.firestore(app: FirebaseApp)` Returns the `FirebaseFirestore` instance of a given `FirebaseApp`. |
| `FirebaseFirestore` | `Firebase.firestore(database: String)` Returns the `FirebaseFirestore` instance of the default `FirebaseApp`, given the database name. |
| `inline T?` | `<T : Any?> DocumentSnapshot.getField( fieldPath: FieldPath, serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior )` Returns the value at the field, converted to a POJO, or null if the field or document doesn't exist. |
| `inline T?` | `<T : Any?> DocumentSnapshot.getField(fieldPath: FieldPath)` Returns the value at the field, converted to a POJO, or null if the field or document doesn't exist. |
| `inline T?` | `<T : Any?> DocumentSnapshot.getField( field: String, serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior )` Returns the value at the field, converted to a POJO, or null if the field or document doesn't exist. |
| `inline T?` | `<T : Any?> DocumentSnapshot.getField(field: String)` Returns the value at the field, converted to a POJO, or null if the field or document doesn't exist. |
| `Flow<DocumentSnapshot>` | `DocumentReference.snapshots(metadataChanges: MetadataChanges)` Starts listening to the document referenced by this `DocumentReference` with the given options and emits its values via a `Flow`. |
| `Flow<QuerySnapshot>` | `Query.snapshots(metadataChanges: MetadataChanges)` Starts listening to this query with the given options and emits its values via a `Flow`. |
| `inline T?` | `<T : Any?> DocumentSnapshot.toObject()` Returns the contents of the document converted to a POJO or null if the document doesn't exist. |
| `inline T?` | `<T : Any?> DocumentSnapshot.toObject( serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior )` Returns the contents of the document converted to a POJO or null if the document doesn't exist. |
| `inline T` | `<T : Any> QueryDocumentSnapshot.toObject()` Returns the contents of the document converted to a POJO. |
| `inline T` | `<T : Any> QueryDocumentSnapshot.toObject( serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior )` Returns the contents of the document converted to a POJO. |
| `inline List<T>` | `<T : Any> QuerySnapshot.toObjects()` Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a list. |
| `inline List<T>` | `<T : Any> QuerySnapshot.toObjects( serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior )` Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a list. |

## Extension properties summary

|---|---|
| `FirebaseFirestore` | `Firebase.firestore` Returns the `FirebaseFirestore` instance of the default `FirebaseApp`. |

## Top-level functions

### firestoreSettings

```
fun firestoreSettings(init: FirebaseFirestoreSettings.Builder.() -> Unit): FirebaseFirestoreSettings
```

Returns a `FirebaseFirestoreSettings` instance initialized using the `init` function.

### memoryCacheSettings

```
fun memoryCacheSettings(init: MemoryCacheSettings.Builder.() -> Unit): MemoryCacheSettings
```

### memoryEagerGcSettings

```
fun memoryEagerGcSettings(init: MemoryEagerGcSettings.Builder.() -> Unit): MemoryEagerGcSettings
```

### memoryLruGcSettings

```
fun memoryLruGcSettings(init: MemoryLruGcSettings.Builder.() -> Unit): MemoryLruGcSettings
```

### persistentCacheSettings

```
fun persistentCacheSettings(init: PersistentCacheSettings.Builder.() -> Unit): PersistentCacheSettings
```

## Extension functions

### dataObjects

```
inline fun <T : Any> DocumentReference.dataObjects(
    metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE
): Flow<T?>
```

Starts listening to the document referenced by this `DocumentReference` with the given options and emits its values converted to a POJO via a `Flow`.

- When the returned flow starts being collected, an `EventListener` will be attached.

- When the flow completes, the listener will be removed.

| Parameters |
|---|---|
| `<T : Any>` | The type of the object to convert to. |
| `metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE` | controls metadata-only changes. Default: `MetadataChanges.EXCLUDE` |

### dataObjects

```
inline fun <T : Any> Query.dataObjects(
    metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE
): Flow<List<T>>
```

Starts listening to this query with the given options and emits its values converted to a POJO via a `Flow`.

- When the returned flow starts being collected, an `EventListener` will be attached.

- When the flow completes, the listener will be removed.

| Parameters |
|---|---|
| `<T : Any>` | The type of the object to convert to. |
| `metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE` | controls metadata-only changes. Default: `MetadataChanges.EXCLUDE` |

### firestore

```
fun Firebase.firestore(app: FirebaseApp, database: String): FirebaseFirestore
```

Returns the `FirebaseFirestore` instance of a given `FirebaseApp` and database name.

### firestore

```
fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore
```

Returns the `FirebaseFirestore` instance of a given `FirebaseApp`.

### firestore

```
fun Firebase.firestore(database: String): FirebaseFirestore
```

Returns the `FirebaseFirestore` instance of the default `FirebaseApp`, given the database name.

### getField

```
inline fun <T : Any?> DocumentSnapshot.getField(
    fieldPath: FieldPath,
    serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior
): T?
```

Returns the value at the field, converted to a POJO, or null if the field or document doesn't exist.

| Parameters |
|---|---|
| `<T : Any?>` | The type to convert the field value to. |
| `fieldPath: FieldPath` | The path to the field. |
| `serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior` | Configures the behavior for server timestamps that have not yet ```kotlin been set to their final value. @return ``` The value at the given field or null. |

### getField

```
inline fun <T : Any?> DocumentSnapshot.getField(fieldPath: FieldPath): T?
```

Returns the value at the field, converted to a POJO, or null if the field or document doesn't exist.

| Parameters |
|---|---|
| `<T : Any?>` | The type to convert the field value to. |
| `fieldPath: FieldPath` | The path to the field. |

| Returns |
|---|---|
| `T?` | The value at the given field or null. |

### getField

```
inline fun <T : Any?> DocumentSnapshot.getField(
    field: String,
    serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior
): T?
```

Returns the value at the field, converted to a POJO, or null if the field or document doesn't exist.

| Parameters |
|---|---|
| `<T : Any?>` | The type to convert the field value to. |
| `field: String` | The path to the field. |
| `serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior` | Configures the behavior for server timestamps that have not yet ```kotlin been set to their final value. @return ``` The value at the given field or null. |

### getField

```
inline fun <T : Any?> DocumentSnapshot.getField(field: String): T?
```

Returns the value at the field, converted to a POJO, or null if the field or document doesn't exist.

| Parameters |
|---|---|
| `<T : Any?>` | The type to convert the field value to. |
| `field: String` | The path to the field. |

| Returns |
|---|---|
| `T?` | The value at the given field or null. |

### snapshots

```
fun DocumentReference.snapshots(
    metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE
): Flow<DocumentSnapshot>
```

Starts listening to the document referenced by this `DocumentReference` with the given options and emits its values via a `Flow`.

- When the returned flow starts being collected, an `EventListener` will be attached.

- When the flow completes, the listener will be removed.

| Parameters |
|---|---|
| `metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE` | controls metadata-only changes. Default: `MetadataChanges.EXCLUDE` |

### snapshots

```
fun Query.snapshots(
    metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE
): Flow<QuerySnapshot>
```

Starts listening to this query with the given options and emits its values via a `Flow`.

- When the returned flow starts being collected, an `EventListener` will be attached.

- When the flow completes, the listener will be removed.

| Parameters |
|---|---|
| `metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE` | controls metadata-only changes. Default: `MetadataChanges.EXCLUDE` |

### toObject

```
inline fun <T : Any?> DocumentSnapshot.toObject(): T?
```

Returns the contents of the document converted to a POJO or null if the document doesn't exist.

| Parameters |
|---|---|
| `<T : Any?>` | The type of the object to create. |

| Returns |
|---|---|
| `T?` | The contents of the document in an object of type T or null if the document doesn't ```kotlin exist. ``` |

### toObject

```
inline fun <T : Any?> DocumentSnapshot.toObject(
    serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior
): T?
```

Returns the contents of the document converted to a POJO or null if the document doesn't exist.

| Parameters |
|---|---|
| `<T : Any?>` | The type of the object to create. |
| `serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior` | Configures the behavior for server timestamps that have not yet ```kotlin been set to their final value. @return ``` The contents of the document in an object of type T or null if the document doesn't ```kotlin exist. ``` |

### toObject

```
inline fun <T : Any> QueryDocumentSnapshot.toObject(): T
```

Returns the contents of the document converted to a POJO.

| Parameters |
|---|---|
| `<T : Any>` | The type of the object to create. |

| Returns |
|---|---|
| `T` | The contents of the document in an object of type T. |

### toObject

```
inline fun <T : Any> QueryDocumentSnapshot.toObject(
    serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior
): T
```

Returns the contents of the document converted to a POJO.

| Parameters |
|---|---|
| `<T : Any>` | The type of the object to create. |
| `serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior` | Configures the behavior for server timestamps that have not yet ```kotlin been set to their final value. @return ``` The contents of the document in an object of type T. |

### toObjects

```
inline fun <T : Any> QuerySnapshot.toObjects(): List<T>
```

Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a list.

| Parameters |
|---|---|
| `<T : Any>` | The POJO type used to convert the documents in the list. |

### toObjects

```
inline fun <T : Any> QuerySnapshot.toObjects(
    serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior
): List<T>
```

Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a list.

| Parameters |
|---|---|
| `<T : Any>` | The POJO type used to convert the documents in the list. |
| `serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior` | Configures the behavior for server timestamps that have not yet ```kotlin been set to their final value. ``` |

## Extension properties

### firestore

```
val Firebase.firestore: FirebaseFirestore
```

Returns the `FirebaseFirestore` instance of the default `FirebaseApp`.