# CollectionReference

# CollectionReference


```
public class CollectionReference extends Query
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/kotlin/java/lang/Object.html) |||
| ↳ | [com.google.firebase.firestore.Query](https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query) ||
|   | ↳ | [com.google.firebase.firestore.CollectionReference](https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference) |

*** ** * ** ***

A `CollectionReference` can be used for adding documents, getting document references, and querying for documents (using the methods inherited from `Query`).

**Subclassing Note**: Cloud Firestore classes are not meant to be subclassed except for use in test mocks. Subclassing is not supported in production code and new SDK releases may break code that does so.

## Summary

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference#add(java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html data)` Adds a new document to this collection with the specified data, assigning it a document ID automatically. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference#document()()` Returns a `DocumentReference` pointing to a new document with an auto-generated ID within this collection. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference#document(java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html documentPath)` Gets a `DocumentReference` instance that refers to the document at the specified path within this collection. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference#getId()()` |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference#getParent()()` Gets a `DocumentReference` to the document that contains this collection. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/CollectionReference#getPath()()` Gets the path of this collection (relative to the root of the database) as a slash-separated string. |

| ### Inherited fields |
|---|
| From [com.google.firebase.firestore.Query](https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query) |---|---| | `final https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FirebaseFirestore` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#firestore()` | |

| ### Inherited methods |
|---|
| From [com.google.firebase.firestore.Query](https://firebase.google.com/docs/reference/android/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/ListenerRegistration` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#addSnapshotListener(com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/EventListener<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot> listener)` Starts listening to this query. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/ListenerRegistration` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#addSnapshotListener(android.app.Activity,com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/android/app/Activity.html activity, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/EventListener<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot> listener )` Starts listening to this query using an Activity-scoped listener. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/ListenerRegistration` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#addSnapshotListener(java.util.concurrent.Executor,com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/EventListener<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot> listener )` Starts listening to this query. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/ListenerRegistration` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#addSnapshotListener(com.google.firebase.firestore.MetadataChanges,com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/MetadataChanges metadataChanges, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/EventListener<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot> listener )` Starts listening to this query with the given options. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/ListenerRegistration` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#addSnapshotListener(com.google.firebase.firestore.SnapshotListenOptions,com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/SnapshotListenOptions options, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/EventListener<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot> listener )` Starts listening to this query with the given options. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/ListenerRegistration` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#addSnapshotListener(android.app.Activity,com.google.firebase.firestore.MetadataChanges,com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/android/app/Activity.html activity, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/MetadataChanges metadataChanges, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/EventListener<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot> listener )` Starts listening to this query with the given options, using an Activity-scoped listener. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/ListenerRegistration` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#addSnapshotListener(java.util.concurrent.Executor,com.google.firebase.firestore.MetadataChanges,com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/MetadataChanges metadataChanges, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/EventListener<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot> listener )` Starts listening to this query with the given options. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/AggregateQuery` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#aggregate(com.google.firebase.firestore.AggregateField,com.google.firebase.firestore.AggregateField...)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/AggregateField aggregateField, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html AggregateField[] aggregateFields )` Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/AggregateQuery` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#count()()` Returns a query that counts the documents in the result set of this query. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#endAt(java.lang.Object...)(Object[] fieldValues)` Creates and returns a new `Query` that ends at the provided fields relative to the order of the query. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#endAt(com.google.firebase.firestore.DocumentSnapshot)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentSnapshot snapshot)` Creates and returns a new `Query` that ends at the provided document (inclusive). | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#endBefore(java.lang.Object...)(Object[] fieldValues)` Creates and returns a new `Query` that ends before the provided fields relative to the order of the query. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#endBefore(com.google.firebase.firestore.DocumentSnapshot)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentSnapshot snapshot)` Creates and returns a new `Query` that ends before the provided document (exclusive). | | `boolean` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#equals(java.lang.Object)(https://developer.android.com/reference/kotlin/java/lang/Object.html o)` | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#get()()` Executes the query and returns the results as a `QuerySnapshot`. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/QuerySnapshot>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#get(com.google.firebase.firestore.Source)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Source source)` Executes the query and returns the results as a `QuerySnapshot`. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FirebaseFirestore` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#getFirestore()()` Gets the Cloud Firestore instance associated with this query. | | `int` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#hashCode()()` | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#limit(long)(long limit)` Creates and returns a new `Query` that only returns the first matching documents up to the specified number. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#limitToLast(long)(long limit)` Creates and returns a new `Query` that only returns the last matching documents up to the specified number. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#orderBy(java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field)` Creates and returns a new `Query` that's additionally sorted by the specified field. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#orderBy(com.google.firebase.firestore.FieldPath)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath)` Creates and returns a new `Query` that's additionally sorted by the specified field. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#orderBy(java.lang.String,com.google.firebase.firestore.Query.Direction)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query.Direction direction)` Creates and returns a new `Query` that's additionally sorted by the specified field, optionally in descending order instead of ascending. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#orderBy(com.google.firebase.firestore.FieldPath,com.google.firebase.firestore.Query.Direction)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query.Direction direction)` Creates and returns a new `Query` that's additionally sorted by the specified field, optionally in descending order instead of ascending. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#startAfter(java.lang.Object...)(Object[] fieldValues)` Creates and returns a new `Query` that starts after the provided fields relative to the order of the query. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#startAfter(com.google.firebase.firestore.DocumentSnapshot)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentSnapshot snapshot)` Creates and returns a new `Query` that starts after the provided document (exclusive). | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#startAt(java.lang.Object...)(Object[] fieldValues)` Creates and returns a new `Query` that starts at the provided fields relative to the order of the query. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#startAt(com.google.firebase.firestore.DocumentSnapshot)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentSnapshot snapshot)` Creates and returns a new `Query` that starts at the provided document (inclusive). | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#where(com.google.firebase.firestore.Filter)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Filter filter)` Creates and returns a new `Query` with the additional filter. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereArrayContains(java.lang.String,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field, the value must be an array, and that the array must contain the provided value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereArrayContains(com.google.firebase.firestore.FieldPath,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field, the value must be an array, and that the array must contain the provided value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereArrayContainsAny(java.lang.String,java.util.List<? extends java.lang.Object>)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/List.html<https://developer.android.com/reference/kotlin/java/lang/Object.html> values)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field, the value must be an array, and that the array must contain at least one value from the provided list. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereArrayContainsAny(com.google.firebase.firestore.FieldPath,java.util.List<? extends java.lang.Object>)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/List.html<https://developer.android.com/reference/kotlin/java/lang/Object.html> values )` Creates and returns a new `Query` with the additional filter that documents must contain the specified field, the value must be an array, and that the array must contain at least one value from the provided list. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereEqualTo(java.lang.String,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be equal to the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereEqualTo(com.google.firebase.firestore.FieldPath,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be equal to the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereGreaterThan(java.lang.String,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be greater than the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereGreaterThan(com.google.firebase.firestore.FieldPath,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be greater than the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereGreaterThanOrEqualTo(java.lang.String,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be greater than or equal to the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereGreaterThanOrEqualTo(com.google.firebase.firestore.FieldPath,java.lang.Object)( @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value )` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be greater than or equal to the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereIn(java.lang.String,java.util.List<? extends java.lang.Object>)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/List.html<https://developer.android.com/reference/kotlin/java/lang/Object.html> values)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value must equal one of the values from the provided list. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereIn(com.google.firebase.firestore.FieldPath,java.util.List<? extends java.lang.Object>)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/List.html<https://developer.android.com/reference/kotlin/java/lang/Object.html> values)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value must equal one of the values from the provided list. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereLessThan(java.lang.String,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be less than the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereLessThan(com.google.firebase.firestore.FieldPath,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be less than the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereLessThanOrEqualTo(java.lang.String,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be less than or equal to the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereLessThanOrEqualTo(com.google.firebase.firestore.FieldPath,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value should be less than or equal to the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereNotEqualTo(java.lang.String,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value does not equal the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereNotEqualTo(com.google.firebase.firestore.FieldPath,java.lang.Object)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/Object.html value)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value does not equal the specified value. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereNotIn(java.lang.String,java.util.List<? extends java.lang.Object>)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html field, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/List.html<https://developer.android.com/reference/kotlin/java/lang/Object.html> values)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value does not equal any of the values from the provided list. | | `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/Query#whereNotIn(com.google.firebase.firestore.FieldPath,java.util.List<? extends java.lang.Object>)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldPath fieldPath, @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/util/List.html<https://developer.android.com/reference/kotlin/java/lang/Object.html> values)` Creates and returns a new `Query` with the additional filter that documents must contain the specified field and the value does not equal any of the values from the provided list. | |

## Public methods

### add

```
public @NonNull Task<DocumentReference> add(@NonNull Object data)
```

Adds a new document to this collection with the specified data, assigning it a document ID automatically.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/Object.html data` | The data to write to the document (like a Map or a POJO containing the desired document contents). |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference>` | A Task that will be resolved with the `DocumentReference` of the newly created document. |

### document

```
public @NonNull DocumentReference document()
```

Returns a `DocumentReference` pointing to a new document with an auto-generated ID within this collection.

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference` | A `DocumentReference` pointing to a new document with an auto-generated ID. |

### document

```
public @NonNull DocumentReference document(@NonNull String documentPath)
```

Gets a `DocumentReference` instance that refers to the document at the specified path within this collection.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html documentPath` | A slash-separated relative path to a document. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference` | The `DocumentReference` instance. |

### getId

```
public @NonNull String getId()
```

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html` | The ID of the collection. |

### getParent

```
public @Nullable DocumentReference getParent()
```

Gets a `DocumentReference` to the document that contains this collection. Only subcollections are contained in a document. For root collections, returns `null`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentReference` | The `DocumentReference` that contains this collection or `null` if this is a root collection. |

### getPath

```
public @NonNull String getPath()
```

Gets the path of this collection (relative to the root of the database) as a slash-separated string.

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html` | The path of this collection. |