Firebase. Firestore. WriteBatch
A batch of write operations, used to perform multiple writes as a single atomic unit.
Summary
A WriteBatch
object can be acquired by calling FirebaseFirestore.StartBatch. It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until CommitAsync is called.
Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data.
Public functions |
|
---|---|
CommitAsync()
|
Task
Commits all of the writes in this write batch as a single atomic unit.
|
Delete(DocumentReference documentReference)
|
Deletes the document referenced by the provided
DocumentReference . |
Set(DocumentReference documentReference, object documentData, SetOptions options)
|
Writes to the document referred to by the provided
DocumentReference . |
Update(DocumentReference documentReference, IDictionary< string, object > updates)
|
Updates fields in the document referred to by the provided
DocumentReference . |
Update(DocumentReference documentReference, string field, object value)
|
Updates the field in the document referred to by the provided
DocumentReference . |
Update(DocumentReference documentReference, IDictionary< FieldPath, object > updates)
|
Updates fields in the document referred to by the provided
DocumentReference . |
Public functions
CommitAsync
Task CommitAsync()
Commits all of the writes in this write batch as a single atomic unit.
Details | |
---|---|
Returns |
The write result of the server operation. The task will not complete while the client is offline, though local changes will be visible immediately.
|
Delete
WriteBatch Delete( DocumentReference documentReference )
Deletes the document referenced by the provided DocumentReference
.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
This batch, for the purposes of method chaining.
|
Set
WriteBatch Set( DocumentReference documentReference, object documentData, SetOptions options )
Writes to the document referred to by the provided DocumentReference
.
If the document does not yet exist, it will be created. If you pass options , the provided data can be merged into an existing document.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
This batch, for the purposes of method chaining.
|
Update
WriteBatch Update( DocumentReference documentReference, IDictionary< string, object > updates )
Updates fields in the document referred to by the provided DocumentReference
.
If no document exists yet, the update will fail.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
This batch, for the purposes of method chaining.
|
Update
WriteBatch Update( DocumentReference documentReference, string field, object value )
Updates the field in the document referred to by the provided DocumentReference
.
If no document exists yet, the update will fail.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
This batch, for the purposes of method chaining.
|
Update
WriteBatch Update( DocumentReference documentReference, IDictionary< FieldPath, object > updates )
Updates fields in the document referred to by the provided DocumentReference
.
If no document exists yet, the update will fail.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
This batch, for the purposes of method chaining.
|