java.lang.Object |
↳ |
com.google.firebase.firestore.Transaction |
Class Overview
A Transaction is passed to a Function to provide the methods to read and write data within the
transaction context.
Subclassing 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.
Summary
Nested Classes |
interface |
Transaction.Function<TResult> |
An interface for providing code to be executed within a transaction context. |
Public Methods |
Transaction
|
delete(DocumentReference documentRef)
Deletes the document referred to by the provided DocumentReference.
|
DocumentSnapshot
|
get(DocumentReference documentRef)
Reads the document referenced by this DocumentReference
|
Transaction
|
set(DocumentReference documentRef, Map<String, Object> data)
Overwrites the document referred to by the provided DocumentReference.
|
Transaction
|
set(DocumentReference documentRef, Map<String, Object> data, SetOptions options)
Writes to the document referred to by the provided DocumentReference.
|
Transaction
|
set(DocumentReference documentRef, Object pojo)
Overwrites the document referred to by the provided DocumentReference.
|
Transaction
|
set(DocumentReference documentRef, Object pojo, SetOptions options)
Writes to the document referred to by the provided DocumentReference.
|
Transaction
|
update(DocumentReference documentRef, Map<String, Object> data)
Updates fields in the document referred to by the provided DocumentReference.
|
Transaction
|
update(DocumentReference documentRef, String field, Object value, Object... moreFieldsAndValues)
Updates fields in the document referred to by the provided DocumentReference.
|
Transaction
|
update(DocumentReference documentRef, FieldPath fieldPath, Object value, Object... moreFieldsAndValues)
Updates fields in the document referred to by the provided DocumentReference.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public Methods
Deletes the document referred to by the provided DocumentReference.
Parameters |
documentRef |
DocumentReference : The DocumentReference to delete. |
Returns |
Transaction |
This Transaction instance. Used for chaining method calls.
|
Reads the document referenced by this DocumentReference
Parameters |
documentRef |
DocumentReference : The DocumentReference to read. |
Returns |
DocumentSnapshot |
The contents of the Document at this DocumentReference.
|
Overwrites the document referred to by the provided DocumentReference. If the document does not
yet exist, it will be created. If a document already exists, it will be overwritten.
Parameters |
documentRef |
DocumentReference : The DocumentReference to overwrite. |
data |
Map : A map of the fields and values for the document. |
Returns |
Transaction |
This Transaction instance. Used for chaining method calls.
|
Writes to the document referred to by the provided DocumentReference. 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.
Parameters |
documentRef |
DocumentReference : The DocumentReference to overwrite. |
data |
Map : A map of the fields and values for the document. |
options |
SetOptions : An object to configure the set behavior. |
Returns |
Transaction |
This Transaction instance. Used for chaining method calls.
|
Overwrites the document referred to by the provided DocumentReference. If the document does not
yet exist, it will be created. If a document already exists, it will be overwritten.
Parameters |
documentRef |
DocumentReference : The DocumentReference to overwrite. |
pojo |
Object : The POJO that will be used to populate the document contents |
Returns |
Transaction |
This Transaction instance. Used for chaining method calls.
|
Writes to the document referred to by the provided DocumentReference. 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.
Parameters |
documentRef |
DocumentReference : The DocumentReference to overwrite. |
pojo |
Object : The POJO that will be used to populate the document contents |
options |
SetOptions : An object to configure the set behavior. |
Returns |
Transaction |
This Transaction instance. Used for chaining method calls.
|
Updates fields in the document referred to by the provided DocumentReference. If no document
exists yet, the update will fail.
Parameters |
documentRef |
DocumentReference : The DocumentReference to update. |
data |
Map : A map of field / value pairs to update. Fields can contain dots to reference nested
fields within the document. |
Returns |
Transaction |
This Transaction instance. Used for chaining method calls.
|
public
Transaction
update
(DocumentReference documentRef, String field, Object value, Object... moreFieldsAndValues)
Updates fields in the document referred to by the provided DocumentReference. If no document
exists yet, the update will fail.
Parameters |
documentRef |
DocumentReference : The DocumentReference to update. |
field |
String : The first field to update. Fields can contain dots to reference a nested field
within the document. |
value |
Object : The first value |
moreFieldsAndValues |
Object : Additional field/value pairs. |
Returns |
Transaction |
This Transaction instance. Used for chaining method calls.
|
public
Transaction
update
(DocumentReference documentRef, FieldPath fieldPath, Object value, Object... moreFieldsAndValues)
Updates fields in the document referred to by the provided DocumentReference. If no document
exists yet, the update will fail.
Parameters |
documentRef |
DocumentReference : The DocumentReference to update. |
fieldPath |
FieldPath : The first field to update. |
value |
Object : The first value |
moreFieldsAndValues |
Object : Additional field/value pairs. |
Returns |
Transaction |
This Transaction instance. Used for chaining method calls.
|