firebase:: firestore:: Transaction
#include <transaction.h>
Transaction provides methods to read and write data within a transaction.
Summary
You cannot create aTransaction directly; useFirestore::RunTransaction() function instead.
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 | |
|---|---|
Transaction(constTransaction & other)Deleted copy constructor. | |
~Transaction()Destructor. |
Public functions | |
|---|---|
Delete(constDocumentReference & document) | virtual voidDeletes the document referred to by the provided reference. |
Get(constDocumentReference & document,Error *error_code, std::string *error_message) | virtualDocumentSnapshotReads the document referred by the provided reference. |
Set(constDocumentReference & document, constMapFieldValue & data, constSetOptions & options) | virtual voidWrites to the document referred to by the provided reference. |
Update(constDocumentReference & document, constMapFieldValue & data) | virtual voidUpdates fields in the document referred to by the provided reference. |
Update(constDocumentReference & document, constMapFieldPathValue & data) | virtual voidUpdates fields in the document referred to by the provided reference. |
operator=(constTransaction & other)=delete | Deleted copy assignment operator. |
Protected functions | |
|---|---|
Transaction()=default | Default constructor, to be used only for mocking a Transaction. |
Public functions
Delete
virtualvoidDelete(constDocumentReference&document)
Deletes the document referred to by the provided reference.
| Details | |||
|---|---|---|---|
| Parameters |
|
Get
virtualDocumentSnapshotGet(constDocumentReference&document,Error*error_code,std::string*error_message)
Reads the document referred by the provided reference.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
| ||||||
| Returns | The contents of the document at thisDocumentReference or invalidDocumentSnapshot if there is any error. |
Set
virtualvoidSet(constDocumentReference&document,constMapFieldValue&data,constSetOptions&options)
Writes to the document referred to by the provided reference.
If the document does not yet exist, it will be created. If you passSetOptions, the provided data can be merged into an existing document.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
Transaction
Transaction(constTransaction&other)=delete
Deleted copy constructor.
ATransaction object is only valid for the duration of the callback you pass toFirestore::RunTransaction() and cannot be copied.
Update
virtualvoidUpdate(constDocumentReference&document,constMapFieldValue&data)
Updates fields in the document referred to by the provided reference.
If no document exists yet, the update will fail.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
Update
virtualvoidUpdate(constDocumentReference&document,constMapFieldPathValue&data)
Updates fields in the document referred to by the provided reference.
If no document exists yet, the update will fail.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
operator=
Transaction&operator=(constTransaction&other)=delete
Deleted copy assignment operator.
ATransaction object is only valid for the duration of the callback you pass toFirestore::RunTransaction() and cannot be copied.
~Transaction
virtual~Transaction()
Destructor.
Protected functions
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.