Class WriteBatch (2.5.0)

public sealed class WriteBatch

A batch of write operations, to be applied in a single commit.

Inheritance

Object > WriteBatch

Namespace

Google.Cloud.Firestore

Assembly

Google.Cloud.Firestore.dll

Methods

CommitAsync(CancellationToken)

public Task<IList<WriteResult>> CommitAsync(CancellationToken cancellationToken = default(CancellationToken))

Commits the batch on the server.

Parameter
NameDescription
cancellationTokenCancellationToken
Returns
TypeDescription
Task<IList<WriteResult>>

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
NameDescription
documentReferenceDocumentReference

A document reference indicating the path of the document to create. Must not be null.

documentDataObject

The data for the document. Must not be null.

Returns
TypeDescription
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
NameDescription
documentReferenceDocumentReference

A document reference indicating the path of the document to delete. Must not be null.

preconditionPrecondition

Optional precondition for deletion. May be null, in which case the deletion is unconditional.

Returns
TypeDescription
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
NameDescription
documentReferenceDocumentReference

A document reference indicating the path of the document to update. Must not be null.

documentDataObject

The data to store in the document. Must not be null.

optionsSetOptions

The options to use when setting data in the document. May be null, which is equivalent to Overwrite.

Returns
TypeDescription
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
NameDescription
documentReferenceDocumentReference

A document reference indicating the path of the document to update. Must not be null.

updatesIDictionary<FieldPath, Object>

The 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.

preconditionPrecondition

Optional precondition for updating the document. May be null, which is equivalent to MustExist.

Returns
TypeDescription
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
NameDescription
documentReferenceDocumentReference

A document reference indicating the path of the document to update. Must not be null.

updatesIDictionary<String, Object>

The 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.

preconditionPrecondition

Optional precondition for updating the document. May be null, which is equivalent to MustExist.

Returns
TypeDescription
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
NameDescription
documentReferenceDocumentReference

A document reference indicating the path of the document to update. Must not be null.

fieldString

The dot-separated name of the field to update. Must not be null.

valueObject

The new value for the field. May be null.

preconditionPrecondition

Optional precondition for updating the document. May be null, which is equivalent to MustExist.

Returns
TypeDescription
WriteBatch

This batch, for the purposes of method chaining.