firebase:: firestore:: DocumentChange
#include <document_change.h>
ADocumentChange represents a change to the documents matching a query.
Summary
DocumentChange contains the document affected and the type of change that occurred (added, modified, or removed).
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 | |
|---|---|
DocumentChange()Creates an invalidDocumentChange that has to be reassigned before it can be used. | |
DocumentChange(constDocumentChange & other)Copy constructor. | |
DocumentChange(DocumentChange && other)Move constructor. | |
~DocumentChange() |
Public types | |
|---|---|
Type{ | enum An enumeration of snapshot diff types. |
Public static attributes | |
|---|---|
npos = static_cast | constexpr std::size_tThe sentinel index used as a return value to indicate no matches. |
Public functions | |
|---|---|
document() const | virtualDocumentSnapshotThe document affected by this change. |
is_valid() const | boolReturns true if this DocumentChange is valid, false if it is not valid. |
new_index() const | virtual std::size_tThe index of the changed document in the result set immediately after thisDocumentChange (that is, supposing that all priorDocumentChange objects and the currentDocumentChange object have been applied). |
old_index() const | virtual std::size_tThe index of the changed document in the result set immediately prior to thisDocumentChange (that is, supposing that all priorDocumentChange objects have been applied). |
operator=(constDocumentChange & other) | Copy assignment operator. |
operator=(DocumentChange && other) | Move assignment operator. |
type() const | virtualTypeReturns the type of change that occurred (added, modified, or removed). |
Public types
Type
TypePublic static attributes
npos
constexprstd::size_tnpos=static_cast<std::size_t>(-1)
The sentinel index used as a return value to indicate no matches.
Public functions
DocumentChange
DocumentChange()
Creates an invalidDocumentChange that has to be reassigned before it can be used.
Calling any member function on an invalidDocumentChange 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.
DocumentChange
DocumentChange(constDocumentChange&other)
Copy constructor.
DocumentChange is immutable and can be efficiently copied (no deep copy is performed).
| Details | |||
|---|---|---|---|
| Parameters |
|
DocumentChange
DocumentChange(DocumentChange&&other)
Move constructor.
Moving is more efficient than copying for aDocumentChange. After being moved from, aDocumentChange is equivalent to its default-constructed state.
| Details | |||
|---|---|---|---|
| Parameters |
|
document
virtualDocumentSnapshotdocument()const
The document affected by this change.
Returns the newly added or modified document if thisDocumentChange is for an updated document. Returns the deleted document if this document change represents a removal.
is_valid
boolis_valid()const
Returns true if thisDocumentChange is valid, false if it is not valid.
An invalidDocumentChange could be the result of:
- Creating a
DocumentChangeusing the default constructor. - Moving from the
DocumentChange. - Deleting yourFirestore instance, which will invalidate all the
DocumentChangeinstances associated with it.
| Details | |
|---|---|
| Returns | true if this DocumentChange is valid, false if thisDocumentChange is invalid. |
new_index
virtualstd::size_tnew_index()const
The index of the changed document in the result set immediately after thisDocumentChange (that is, supposing that all priorDocumentChange objects and the currentDocumentChange object have been applied).
ReturnsDocumentChange::npos for 'removed' events.
old_index
virtualstd::size_told_index()const
The index of the changed document in the result set immediately prior to thisDocumentChange (that is, supposing that all priorDocumentChange objects have been applied).
ReturnsDocumentChange::npos for 'added' events.
operator=
DocumentChange&operator=(constDocumentChange&other)
Copy assignment operator.
DocumentChange is immutable and can be efficiently copied (no deep copy is performed).
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Reference to the destination DocumentChange. |
operator=
DocumentChange&operator=(DocumentChange&&other)
Move assignment operator.
Moving is more efficient than copying for aDocumentChange. After being moved from, aDocumentChange is equivalent to its default-constructed state.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Reference to the destination DocumentChange. |
~DocumentChange
virtual~DocumentChange()
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.