firebase::firestore::Transaction

#include <transaction.h>

Transaction provides methods to read and write data within a transaction.

Summary

You cannot create a Transaction directly; use Firestore::RunTransaction() function instead.

Constructors and Destructors

Transaction(const Transaction & other)
Deleted copy constructor.
~Transaction()
Destructor.

Public functions

Delete(const DocumentReference & document)
virtual void
Deletes the document referred to by the provided reference.
Get(const DocumentReference & document, Error *error_code, std::string *error_message)
Reads the document referred by the provided reference.
Set(const DocumentReference & document, const MapFieldValue & data, const SetOptions & options)
virtual void
Writes to the document referred to by the provided reference.
Update(const DocumentReference & document, const MapFieldValue & data)
virtual void
Updates fields in the document referred to by the provided reference.
Update(const DocumentReference & document, const MapFieldPathValue & data)
virtual void
Updates fields in the document referred to by the provided reference.
operator=(const Transaction & other)=delete
Deleted copy assignment operator.

Protected functions

Transaction()=default
Default constructor, to be used only for mocking a Transaction.

Public functions

Delete

virtual void Delete(
  const DocumentReference & document
)

Deletes the document referred to by the provided reference.

Details
Parameters
document
The DocumentReference to delete.

Get

virtual DocumentSnapshot Get(
  const DocumentReference & document,
  Error *error_code,
  std::string *error_message
)

Reads the document referred by the provided reference.

Details
Parameters
document
The DocumentReference to read.
error_code
An out parameter to capture an error, if one occurred.
error_message
An out parameter to capture error message, if any.
Returns
The contents of the document at this DocumentReference or invalid DocumentSnapshot if there is any error.

Set

virtual void Set(
  const DocumentReference & document,
  const MapFieldValue & data,
  const SetOptions & options
)

Writes to the document referred to by the provided reference.

If the document does not yet exist, it will be created. If you pass SetOptions, the provided data can be merged into an existing document.

Details
Parameters
document
The DocumentReference to overwrite.
data
A map of the fields and values to write to the document.
options
An object to configure the Set() behavior (optional).

Transaction

 Transaction(
  const Transaction & other
)=delete

Deleted copy constructor.

A Transaction object is only valid for the duration of the callback you pass to Firestore::RunTransaction() and cannot be copied.

Update

virtual void Update(
  const DocumentReference & document,
  const MapFieldValue & data
)

Updates fields in the document referred to by the provided reference.

If no document exists yet, the update will fail.

Details
Parameters
document
The DocumentReference to update.
data
A map of field / value pairs to update. Fields can contain dots to reference nested fields within the document.

Update

virtual void Update(
  const DocumentReference & document,
  const MapFieldPathValue & data
)

Updates fields in the document referred to by the provided reference.

If no document exists yet, the update will fail.

Details
Parameters
document
The DocumentReference to update.
data
A map from FieldPath to FieldValue to update.

operator=

Transaction & operator=(
  const Transaction & other
)=delete

Deleted copy assignment operator.

A Transaction object is only valid for the duration of the callback you pass to Firestore::RunTransaction() and cannot be copied.

~Transaction

virtual  ~Transaction()

Destructor.

Protected functions

Transaction

 Transaction()=default

Default constructor, to be used only for mocking a Transaction.