firebase::firestore::DocumentChange

#include <document_change.h>

A DocumentChange 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).

Constructors and Destructors

DocumentChange()
Creates an invalid DocumentChange that has to be reassigned before it can be used.
DocumentChange(const DocumentChange & other)
Copy constructor.
DocumentChange(DocumentChange && other)
Move constructor.
~DocumentChange()

Public types

Type{
  kAdded,
  kModified,
  kRemoved
}
enum
An enumeration of snapshot diff types.

Public static attributes

npos = static_cast(-1)
constexpr std::size_t
The sentinel index used as a return value to indicate no matches.

Public functions

document() const
The document affected by this change.
is_valid() const
bool
Returns true if this DocumentChange is valid, false if it is not valid.
new_index() const
virtual std::size_t
The index of the changed document in the result set immediately after this DocumentChange (that is, supposing that all prior DocumentChange objects and the current DocumentChange object have been applied).
old_index() const
virtual std::size_t
The index of the changed document in the result set immediately prior to this DocumentChange (that is, supposing that all prior DocumentChange objects have been applied).
operator=(const DocumentChange & other)
Copy assignment operator.
operator=(DocumentChange && other)
Move assignment operator.
type() const
virtual Type
Returns the type of change that occurred (added, modified, or removed).

Public types

Type

 Type

An enumeration of snapshot diff types.

Properties
kAdded

Indicates a new document was added to the set of documents matching the query.

kModified

Indicates a document within the query was modified.

kRemoved

Indicates a document within the query was removed (either deleted or no longer matches the query).

Public static attributes

npos

constexpr std::size_t npos = static_cast<std::size_t>(-1)

The sentinel index used as a return value to indicate no matches.

Public functions

DocumentChange

 DocumentChange()

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

Calling any member function on an invalid DocumentChange 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(
  const DocumentChange & other
)

Copy constructor.

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

Details
Parameters
other
DocumentChange to copy from.

DocumentChange

 DocumentChange(
  DocumentChange && other
)

Move constructor.

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

Details
Parameters
other
DocumentChange to move data from.

document

virtual DocumentSnapshot document() const 

The document affected by this change.

Returns the newly added or modified document if this DocumentChange is for an updated document. Returns the deleted document if this document change represents a removal.

is_valid

bool is_valid() const 

Returns true if this DocumentChange is valid, false if it is not valid.

An invalid DocumentChange could be the result of:

Details
Returns
true if this DocumentChange is valid, false if this DocumentChange is invalid.

new_index

virtual std::size_t new_index() const 

The index of the changed document in the result set immediately after this DocumentChange (that is, supposing that all prior DocumentChange objects and the current DocumentChange object have been applied).

Returns DocumentChange::npos for 'removed' events.

old_index

virtual std::size_t old_index() const 

The index of the changed document in the result set immediately prior to this DocumentChange (that is, supposing that all prior DocumentChange objects have been applied).

Returns DocumentChange::npos for 'added' events.

operator=

DocumentChange & operator=(
  const DocumentChange & other
)

Copy assignment operator.

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

Details
Parameters
other
DocumentChange to copy from.
Returns
Reference to the destination DocumentChange.

operator=

DocumentChange & operator=(
  DocumentChange && other
)

Move assignment operator.

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

Details
Parameters
other
DocumentChange to move data from.
Returns
Reference to the destination DocumentChange.

type

virtual Type type() const 

Returns the type of change that occurred (added, modified, or removed).

~DocumentChange

virtual  ~DocumentChange()