Methods

commit

commit() returns Promise containing void

Commits all of the writes in this write batch as a single atomic unit.

Returns

non-null Promise containing void A promise that resolves once all of the writes in the batch have been successfully written to the backend as an atomic unit. Note that it won't resolve while you're offline.

delete

delete(documentRef) returns firebase.firestore.WriteBatch

Deletes the document referred to by the provided DocumentReference.

Parameter

documentRef

firebase.firestore.DocumentReference

A reference to the document to be deleted.

Value must not be null.

Returns

non-null firebase.firestore.WriteBatch This WriteBatch instance. Used for chaining method calls.

set

set(documentRef, data, options) returns firebase.firestore.WriteBatch

Writes to the document referred to by the provided DocumentReference. If the document does not exist yet, it will be created. If you pass options, the provided data can be merged into the existing document.

Parameter

documentRef

firebase.firestore.DocumentReference

A reference to the document to be created.

Value must not be null.

data

Object

An object of the fields and values for the document.

Value must not be null.

options

Optional

firebase.firestore.SetOptions

An object to configure the set behavior. Pass {merge: true} to only replace the values specified in the data argument. Fields omitted will remain untouched.

Value must not be null.

Returns

non-null firebase.firestore.WriteBatch This WriteBatch instance. Used for chaining method calls.

update

update(documentRef, ...var_args) returns firebase.firestore.WriteBatch

Updates fields in the document referred to by this DocumentReference. The update will fail if applied to a document that does not exist.

Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects.

Parameter

documentRef

firebase.firestore.DocumentReference

A reference to the document to be updated.

Value must not be null.

var_args

any type

Either an object containing all of the fields and values to update, or a series of arguments alternating between fields (as string or firebase.firestore.FieldPath objects) and values.

Value may be repeated.

Returns

non-null firebase.firestore.WriteBatch This WriteBatch instance. Used for chaining method calls.