A reference to a transaction.TheTransaction object passed to a transaction's updateFunction providesthe methods to read and write data within the transaction context. SeeFirestore.runTransaction().
Index
Constructors
Methods
Constructors
Private constructor
- new
Transaction():Transaction ReturnsTransaction
Methods
delete
- delete(documentRef: DocumentReference<any>):Transaction
Deletes the document referred to by the provided
DocumentReference.Parameters
documentRef:DocumentReference<any>
A reference to the document to be deleted.
ReturnsTransaction
This
Transactioninstance. Used for chaining method calls.
get
- get<T>(documentRef: DocumentReference<T>):Promise<DocumentSnapshot<T>>
Reads the document referenced by the provided
DocumentReference.Type parameters
T
Parameters
documentRef:DocumentReference<T>
A reference to the document to be read.
ReturnsPromise<DocumentSnapshot<T>>
A DocumentSnapshot for the read data.
set
- set<T>(documentRef: DocumentReference<T>, data: Partial<T>, options: SetOptions):Transaction
Writes to the document referred to by the provided
DocumentReference.If the document does not exist yet, it will be created. If you passSetOptions, the provided data can be merged into the existing document.Type parameters
T
Parameters
documentRef:DocumentReference<T>
A reference to the document to be set.
data:Partial<T>
An object of the fields and values for the document.
options:SetOptions
An object to configure the set behavior.
ReturnsTransaction
This
Transactioninstance. Used for chaining method calls.- set<T>(documentRef: DocumentReference<T>, data: T):Transaction
Writes to the document referred to by the provided
DocumentReference.If the document does not exist yet, it will be created. If you passSetOptions, the provided data can be merged into the existing document.Type parameters
T
Parameters
documentRef:DocumentReference<T>
A reference to the document to be set.
data:T
An object of the fields and values for the document.
ReturnsTransaction
This
Transactioninstance. Used for chaining method calls.
update
- update(documentRef: DocumentReference<any>, data: UpdateData):Transaction
Updates fields in the document referred to by the provided
DocumentReference. The update will fail if applied to a document thatdoes not exist.Parameters
documentRef:DocumentReference<any>
A reference to the document to be updated.
data:UpdateData
An object containing the fields and values with which toupdate the document. Fields can contain dots to reference nested fieldswithin the document.
ReturnsTransaction
This
Transactioninstance. Used for chaining method calls.- update(documentRef: DocumentReference<any>, field: string |FieldPath, value: any, ...moreFieldsAndValues: any[]):Transaction
Updates fields in the document referred to by the provided
DocumentReference. The update will fail if applied to a document thatdoes not exist.Nested fields can be updated by providing dot-separated field pathstrings or by providing FieldPath objects.
Parameters
documentRef:DocumentReference<any>
A reference to the document to be updated.
field:string |FieldPath
The first field to update.
value:any
The first value.
Rest...moreFieldsAndValues:any[]
Additional key/value pairs.
ReturnsTransaction
A Promise resolved once the data has been successfully writtento the backend (Note that it won't resolve while you're offline).
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 2022-07-27 UTC.