QuerySnapshot

class QuerySnapshot : Iterable


A QuerySnapshot contains the results of a query. It can contain zero or more DocumentSnapshot objects.

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 functions

Boolean
equals(obj: Any?)
(Mutable)List<DocumentChange!>

Returns the list of documents that changed since the last snapshot.

(Mutable)List<DocumentChange!>

Returns the list of documents that changed since the last snapshot.

(Mutable)List<DocumentSnapshot!>

Returns the documents in this QuerySnapshot as a List in order of the query.

Query
Int
Boolean

Returns true if there are no documents in the QuerySnapshot.

(Mutable)Iterator<QueryDocumentSnapshot!>
Int

Returns the number of documents in the QuerySnapshot.

(Mutable)List<T!>
<T> toObjects(clazz: Class<T!>)

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

(Mutable)List<T!>
<T> toObjects(
    clazz: Class<T!>,
    serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior
)

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

Public properties

SnapshotMetadata!

Extension functions

inline List<T>

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.

inline List<T>

This function is deprecated. Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.

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

This function is deprecated. Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.

Inherited functions

From java.lang.Iterable

Public functions

equals

fun equals(obj: Any?): Boolean

getDocumentChanges

fun getDocumentChanges(): (Mutable)List<DocumentChange!>

Returns the list of documents that changed since the last snapshot. If it's the first snapshot all documents will be in the list as added changes.

Documents with changes only to their metadata will not be included.

Returns
(Mutable)List<DocumentChange!>

The list of document changes since the last snapshot.

getDocumentChanges

fun getDocumentChanges(metadataChanges: MetadataChanges): (Mutable)List<DocumentChange!>

Returns the list of documents that changed since the last snapshot. If it's the first snapshot all documents will be in the list as added changes.

Parameters
metadataChanges: MetadataChanges

Indicates whether metadata-only changes (specifically, only DocumentSnapshot.getMetadata() changed) should be included.

Returns
(Mutable)List<DocumentChange!>

The list of document changes since the last snapshot.

getDocuments

fun getDocuments(): (Mutable)List<DocumentSnapshot!>

Returns the documents in this QuerySnapshot as a List in order of the query.

Returns
(Mutable)List<DocumentSnapshot!>

The list of documents.

getQuery

fun getQuery(): Query

hashCode

fun hashCode(): Int

isEmpty

fun isEmpty(): Boolean

Returns true if there are no documents in the QuerySnapshot.

size

fun size(): Int

Returns the number of documents in the QuerySnapshot.

toObjects

fun <T> toObjects(clazz: Class<T!>): (Mutable)List<T!>

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

Parameters
clazz: Class<T!>

The POJO type used to convert the documents in the list.

toObjects

fun <T> toObjects(
    clazz: Class<T!>,
    serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior
): (Mutable)List<T!>

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

Parameters
clazz: Class<T!>

The POJO type used to convert the documents in the list.

serverTimestampBehavior: DocumentSnapshot.ServerTimestampBehavior

Configures the behavior for server timestamps that have not yet been set to their final value.

Public properties

metadata

val metadataSnapshotMetadata!

Extension functions

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

    been set to their final value.

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.

Deprecation Notice: The Kotlin extensions (KTX) APIs have been added to their respective main modules, and the Kotlin extension (KTX) APIs in com.google.firebase.firebase-database-ktx are now deprecated. As early as April 2024, we'll no longer release KTX modules. For details, see the FAQ about this initiative.

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.

Deprecation Notice: The Kotlin extensions (KTX) APIs have been added to their respective main modules, and the Kotlin extension (KTX) APIs in com.google.firebase.firebase-database-ktx are now deprecated. As early as April 2024, we'll no longer release KTX modules. For details, see the FAQ about this initiative.

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

    been set to their final value.