firebase::firestore::QuerySnapshot

#include <query_snapshot.h>

AQuerySnapshot contains zero or moreDocumentSnapshot objects.

Summary

QuerySnapshot can be iterated using a range-based for loop, and its size can be inspected withempty() andsize().

Note: 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.

Constructors and Destructors

QuerySnapshot()
Creates an invalidQuerySnapshot that has to be reassigned before it can be used.
QuerySnapshot(constQuerySnapshot & other)
Copy constructor.
QuerySnapshot(QuerySnapshot && other)
Move constructor.
~QuerySnapshot()

Public functions

DocumentChanges(MetadataChanges metadata_changes) const
virtual std::vector<DocumentChange >
The list of documents that changed since the last snapshot.
documents() const
virtual std::vector<DocumentSnapshot >
The list of documents in thisQuerySnapshot in order of the query.
empty() const
bool
Checks the emptiness of theQuerySnapshot.
is_valid() const
bool
Returns true if thisQuerySnapshot is valid, false if it is not valid.
metadata() const
Metadata about this snapshot, concerning its source and if it has local modifications.
operator=(constQuerySnapshot & other)
Copy assignment operator.
operator=(QuerySnapshot && other)
Move assignment operator.
query() const
virtualQuery
The query from which you got thisQuerySnapshot.
size() const
virtual std::size_t
Checks the size of theQuerySnapshot.

Public functions

DocumentChanges

virtualstd::vector<DocumentChange>DocumentChanges(MetadataChangesmetadata_changes)const

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.

Details
Parameters
metadata_changes
Indicates whether metadata-only changes (that is, onlyQuerySnapshot::metadata() changed) should be included.
Returns
The list of document changes since the last snapshot.

QuerySnapshot

QuerySnapshot()

Creates an invalidQuerySnapshot that has to be reassigned before it can be used.

Calling any member function on an invalidQuerySnapshot will be a no-op. If the function returns a value, it will return a zero, empty, or invalid value, depending on the type of the value.

QuerySnapshot

QuerySnapshot(constQuerySnapshot&other)

Copy constructor.

QuerySnapshot is immutable and can be efficiently copied (no deep copy is performed).

Details
Parameters
other
QuerySnapshot to copy from.

QuerySnapshot

QuerySnapshot(QuerySnapshot&&other)

Move constructor.

Moving is more efficient than copying for aQuerySnapshot. After being moved from, aQuerySnapshot is equivalent to its default-constructed state.

Details
Parameters
other
QuerySnapshot to move data from.

documents

virtualstd::vector<DocumentSnapshot>documents()const

The list of documents in thisQuerySnapshot in order of the query.

Details
Returns
The list of documents.

empty

boolempty()const

Checks the emptiness of theQuerySnapshot.

Details
Returns
True if there are no documents in theQuerySnapshot.

is_valid

boolis_valid()const

Returns true if thisQuerySnapshot is valid, false if it is not valid.

An invalidQuerySnapshot could be the result of:

Details
Returns
true if thisQuerySnapshot is valid, false if thisQuerySnapshot is invalid.

metadata

virtualSnapshotMetadatametadata()const

Metadata about this snapshot, concerning its source and if it has local modifications.

Details
Returns
The metadata for this document snapshot.

operator=

QuerySnapshot&operator=(constQuerySnapshot&other)

Copy assignment operator.

QuerySnapshot is immutable and can be efficiently copied (no deep copy is performed).

Details
Parameters
other
QuerySnapshot to copy from.
Returns
Reference to the destinationQuerySnapshot.

operator=

QuerySnapshot&operator=(QuerySnapshot&&other)

Move assignment operator.

Moving is more efficient than copying for aQuerySnapshot. After being moved from, aQuerySnapshot is equivalent to its default-constructed state.

Details
Parameters
other
QuerySnapshot to move data from.
Returns
Reference to the destinationQuerySnapshot.

query

virtualQueryquery()const

The query from which you got thisQuerySnapshot.

size

virtualstd::size_tsize()const

Checks the size of theQuerySnapshot.

Details
Returns
The number of documents in theQuerySnapshot.

~QuerySnapshot

virtual~QuerySnapshot()

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 2024-01-23 UTC.