Class UpdateBuilder<T> (3.4.2)

Stay organized with collections Save and categorize content based on your preferences.
public abstract class UpdateBuilder<T>

Abstract class that collects and bundles all write operations for Transaction and WriteBatch.

Inheritance

Object > UpdateBuilder<T>

Type Parameter

NameDescription
T

Fields

committed

protected boolean committed
Field Value
TypeDescription
boolean

Methods

create(DocumentReference documentReference, Object pojo)

public T create(DocumentReference documentReference, Object pojo)

Creates a new Document at the DocumentReference location. It fails the write if the document exists.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to create.

pojoObject

The POJO that will be used to populate the document contents.

Returns
TypeDescription
T

The instance for chaining.

create(DocumentReference documentReference, Map<String,Object> fields)

public T create(DocumentReference documentReference, Map<String,Object> fields)

Creates a new Document at the DocumentReference's location. It fails the write if the document exists.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to create.

fieldsMap<String,Object>

A map of the fields and values for the document.

Returns
TypeDescription
T

The instance for chaining.

delete(DocumentReference documentReference)

public T delete(DocumentReference documentReference)

Deletes the document referred to by this DocumentReference.

Parameter
NameDescription
documentReferenceDocumentReference

The DocumentReference to delete.

Returns
TypeDescription
T

The instance for chaining.

delete(DocumentReference documentReference, Precondition precondition)

public T delete(DocumentReference documentReference, Precondition precondition)

Deletes the document referred to by this DocumentReference.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to delete.

preconditionPrecondition

Precondition for the delete operation.

Returns
TypeDescription
T

The instance for chaining.

getMutationsSize()

public int getMutationsSize()

Get the number of writes.

Returns
TypeDescription
int

set(DocumentReference documentReference, Object pojo)

public T set(DocumentReference documentReference, Object pojo)

Overwrites the document referred to by this DocumentReference. If the document doesn't exist yet, it will be created. If a document already exists, it will be overwritten.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to overwrite.

pojoObject

The POJO that will be used to populate the document contents.

Returns
TypeDescription
T

The instance for chaining.

set(DocumentReference documentReference, Object pojo, SetOptions options)

public T set(DocumentReference documentReference, Object pojo, SetOptions options)

Overwrites the document referred to by this DocumentReference. If the document doesn't exist yet, it will be created. If you pass SetOptions, the provided data can be merged into an existing document.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to overwrite.

pojoObject

The POJO that will be used to populate the document contents.

optionsSetOptions

An object to configure the set behavior.

Returns
TypeDescription
T

The instance for chaining.

set(DocumentReference documentReference, Map<String,Object> fields)

public T set(DocumentReference documentReference, Map<String,Object> fields)

Overwrites the document referred to by this DocumentReference. If the document doesn't exist yet, it will be created. If a document already exists, it will be overwritten.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to overwrite.

fieldsMap<String,Object>

A map of the field paths and values for the document.

Returns
TypeDescription
T

The instance for chaining.

set(DocumentReference documentReference, Map<String,Object> fields, SetOptions options)

public T set(DocumentReference documentReference, Map<String,Object> fields, SetOptions options)

Overwrites the document referred to by this DocumentReference. If the document doesn't exist yet, it will be created. If you pass SetOptions, the provided data can be merged into an existing document.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to overwrite.

fieldsMap<String,Object>

A map of the field paths and values for the document.

optionsSetOptions

An object to configure the set behavior.

Returns
TypeDescription
T

The instance for chaining.

update(DocumentReference documentReference, FieldPath fieldPath, Object value, Object[] moreFieldsAndValues)

public T update(DocumentReference documentReference, FieldPath fieldPath, Object value, Object[] moreFieldsAndValues)

Updates the fields in the document referred to by this DocumentReference. If the document doesn't exist yet, the update will fail.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to update.

fieldPathFieldPath

The first field to set.

valueObject

The first value to set.

moreFieldsAndValuesObject[]

String and Object pairs with more fields to be set.

Returns
TypeDescription
T

The instance for chaining.

update(DocumentReference documentReference, Precondition precondition, FieldPath fieldPath, Object value, Object[] moreFieldsAndValues)

public T update(DocumentReference documentReference, Precondition precondition, FieldPath fieldPath, Object value, Object[] moreFieldsAndValues)

Updates the fields in the document referred to by this DocumentReference. If the document doesn't exist yet, the update will fail.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to update.

preconditionPrecondition

Precondition to enforce on this update.

fieldPathFieldPath

The first field to set.

valueObject

The first value to set.

moreFieldsAndValuesObject[]

String and Object pairs with more fields to be set.

Returns
TypeDescription
T

The instance for chaining.

update(DocumentReference documentReference, Precondition precondition, String field, Object value, Object[] moreFieldsAndValues)

public T update(DocumentReference documentReference, Precondition precondition, String field, Object value, Object[] moreFieldsAndValues)

Updates the fields in the document referred to by this DocumentReference. If the document doesn't exist yet, the update will fail.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to update.

preconditionPrecondition

Precondition to enforce on this update.

fieldString

The first field to set.

valueObject

The first value to set.

moreFieldsAndValuesObject[]

String and Object pairs with more fields to be set.

Returns
TypeDescription
T

The instance for chaining.

update(DocumentReference documentReference, String field, Object value, Object[] moreFieldsAndValues)

public T update(DocumentReference documentReference, String field, Object value, Object[] moreFieldsAndValues)

Updates the fields in the document referred to by this DocumentReference. If the document doesn't exist yet, the update will fail.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to update.

fieldString

The first field to set.

valueObject

The first value to set.

moreFieldsAndValuesObject[]

String and Object pairs with more fields to be set.

Returns
TypeDescription
T

The instance for chaining.

update(DocumentReference documentReference, Map<String,Object> fields)

public T update(DocumentReference documentReference, Map<String,Object> fields)

Updates fields in the document referred to by this DocumentReference. If the document doesn't exist yet, the update will fail.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to update.

fieldsMap<String,Object>

A Map containing the fields and values with which to update the document.

Returns
TypeDescription
T

The instance for chaining.

update(DocumentReference documentReference, Map<String,Object> fields, Precondition precondition)

public T update(DocumentReference documentReference, Map<String,Object> fields, Precondition precondition)

Updates fields in the document referred to by this DocumentReference. If the document doesn't exist yet, the update will fail.

Parameters
NameDescription
documentReferenceDocumentReference

The DocumentReference to update.

fieldsMap<String,Object>

A Map containing the fields and values with which to update the document.

preconditionPrecondition

Precondition to enforce on this update.

Returns
TypeDescription
T

The instance for chaining.