public sealed class WriteBatchReference documentation and code samples for the Firestore API class WriteBatch.
A batch of write operations, to be applied in a single commit.
Namespace
Google.Cloud.FirestoreAssembly
Google.Cloud.Firestore.dll
Methods
CommitAsync(CancellationToken)
public Task<IList<WriteResult>> CommitAsync(CancellationToken cancellationToken = default)Commits the batch on the server.
| Parameter | |
|---|---|
| Name | Description |
cancellationToken |
CancellationToken |
| Returns | |
|---|---|
| Type | Description |
TaskSystem.Collections.Generic.IList`1WriteResult |
The write results from the commit. |
Create(DocumentReference, object)
public WriteBatch Create(DocumentReference documentReference, object documentData)Adds a write operation which will create the specified document with a precondition that it doesn't exist already.
| Parameters | |
|---|---|
| Name | Description |
documentReference |
DocumentReferenceA document reference indicating the path of the document to create. Must not be null. |
documentData |
objectThe data for the document. Must not be null. |
| Returns | |
|---|---|
| Type | Description |
WriteBatch |
This batch, for the purpose of method chaining |
Delete(DocumentReference, Precondition)
public WriteBatch Delete(DocumentReference documentReference, Precondition precondition = null)Adds a write operation that deletes the specified document, with an optional precondition.
| Parameters | |
|---|---|
| Name | Description |
documentReference |
DocumentReferenceA document reference indicating the path of the document to delete. Must not be null. |
precondition |
PreconditionOptional precondition for deletion. May be null, in which case the deletion is unconditional. |
| Returns | |
|---|---|
| Type | Description |
WriteBatch |
This batch, for the purposes of method chaining. |
Set(DocumentReference, object, SetOptions)
public WriteBatch Set(DocumentReference documentReference, object documentData, SetOptions options = null)Adds an operation that sets data in a document, either replacing it completely or merging fields.
| Parameters | |
|---|---|
| Name | Description |
documentReference |
DocumentReferenceA document reference indicating the path of the document to update. Must not be null. |
documentData |
objectThe data to store in the document. Must not be null. |
options |
SetOptionsThe options to use when setting data in the document. May be null, which is equivalent to Overwrite. |
| Returns | |
|---|---|
| Type | Description |
WriteBatch |
This batch, for the purposes of method chaining. |
Update(DocumentReference, IDictionary<FieldPath, object>, Precondition)
public WriteBatch Update(DocumentReference documentReference, IDictionary<FieldPath, object> updates, Precondition precondition = null)Adds an update operation that updates just the specified fields paths in the document, with the corresponding values.
| Parameters | |
|---|---|
| Name | Description |
documentReference |
DocumentReferenceA document reference indicating the path of the document to update. Must not be null. |
updates |
IDictionaryFieldPathobjectThe updates to perform on the document, keyed by the field path to update. Fields not present in this dictionary are not updated. Must not be null or empty. |
precondition |
PreconditionOptional precondition for updating the document. May be null, which is equivalent to MustExist. |
| Returns | |
|---|---|
| Type | Description |
WriteBatch |
This batch, for the purposes of method chaining. |
Update(DocumentReference, IDictionary<string, object>, Precondition)
public WriteBatch Update(DocumentReference documentReference, IDictionary<string, object> updates, Precondition precondition = null)Adds an update operation that updates just the specified fields paths in the document, with the corresponding values.
| Parameters | |
|---|---|
| Name | Description |
documentReference |
DocumentReferenceA document reference indicating the path of the document to update. Must not be null. |
updates |
IDictionarystringobjectThe updates to perform on the document, keyed by the dot-separated field path to update. Fields not present in this dictionary are not updated. Must not be null or empty. |
precondition |
PreconditionOptional precondition for updating the document. May be null, which is equivalent to MustExist. |
| Returns | |
|---|---|
| Type | Description |
WriteBatch |
This batch, for the purposes of method chaining. |
Update(DocumentReference, string, object, Precondition)
public WriteBatch Update(DocumentReference documentReference, string field, object value, Precondition precondition = null)Adds an update operation that updates just the specified field in the document, with the corresponding values.
| Parameters | |
|---|---|
| Name | Description |
documentReference |
DocumentReferenceA document reference indicating the path of the document to update. Must not be null. |
field |
stringThe dot-separated name of the field to update. Must not be null. |
value |
objectThe new value for the field. May be null. |
precondition |
PreconditionOptional precondition for updating the document. May be null, which is equivalent to MustExist. |
| Returns | |
|---|---|
| Type | Description |
WriteBatch |
This batch, for the purposes of method chaining. |