QuerySnapshot

public classQuerySnapshot implementsIterable


AQuerySnapshot contains the results of a query. It can contain zero or moreDocumentSnapshot 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 fields

finalSnapshotMetadata

Public methods

boolean
@NonNullList<DocumentChange>

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

@NonNullList<DocumentChange>

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

@NonNullList<DocumentSnapshot>

Returns the documents in thisQuerySnapshot as a List in order of the query.

@NonNullSnapshotMetadata
@NonNullQuery
int
boolean

Returns true if there are no documents in theQuerySnapshot.

@NonNullIterator<QueryDocumentSnapshot>
int

Returns the number of documents in theQuerySnapshot.

@NonNullList<T>
<T>toObjects(@NonNullClass<T> clazz)

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

@NonNullList<T>
<T>toObjects(
    @NonNullClass<T> clazz,
    @NonNullDocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior
)

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

Extension functions

final @NonNullList<@NonNull T>

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

final @NonNullList<@NonNull T>
<T extends Object>FirestoreKt.toObjects(
    @NonNullQuerySnapshot receiver,
    @NonNullDocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior
)

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

Inherited methods

Fromjava.lang.Iterable

Public fields

metadata

public final SnapshotMetadata metadata

Public methods

equals

public boolean equals(@NullableObject obj)

getDocumentChanges

public @NonNullList<DocumentChangegetDocumentChanges()

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
@NonNullList<DocumentChange>

The list of document changes since the last snapshot.

getDocumentChanges

public @NonNullList<DocumentChangegetDocumentChanges(@NonNullMetadataChanges metadataChanges)

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
@NonNullMetadataChanges metadataChanges

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

Returns
@NonNullList<DocumentChange>

The list of document changes since the last snapshot.

getDocuments

public @NonNullList<DocumentSnapshotgetDocuments()

Returns the documents in thisQuerySnapshot as a List in order of the query.

Returns
@NonNullList<DocumentSnapshot>

The list of documents.

getMetadata

public @NonNullSnapshotMetadata getMetadata()
Returns
@NonNullSnapshotMetadata

The metadata for this query snapshot.

getQuery

public @NonNullQuery getQuery()

hashCode

public int hashCode()

isEmpty

public boolean isEmpty()

Returns true if there are no documents in theQuerySnapshot.

size

public int size()

Returns the number of documents in theQuerySnapshot.

toObjects

public @NonNullList<T> <T>toObjects(@NonNullClass<T> clazz)

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

Parameters
@NonNullClass<T> clazz

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

toObjects

public @NonNullList<T> <T>toObjects(
    @NonNullClass<T> clazz,
    @NonNullDocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior
)

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

Parameters
@NonNullClass<T> clazz

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

@NonNullDocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior

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

Extension functions

FirestoreKt.toObjects

public final @NonNullList<@NonNull T> <T extends Object>FirestoreKt.toObjects(@NonNullQuerySnapshot receiver)

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

Parameters
<T extends Object>

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

FirestoreKt.toObjects

public final @NonNullList<@NonNull T> <T extends Object>FirestoreKt.toObjects(
    @NonNullQuerySnapshot receiver,
    @NonNullDocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior
)

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

Parameters
<T extends Object>

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

@NonNullDocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior

Configures the behavior for server timestamps that have not yet

    been set to their final value.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.