Class UpdateBuilder<T> (3.25.1)

public abstract class UpdateBuilder<T>

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

Inheritance

Object > UpdateBuilder<T>

Type Parameter

Name Description
T

Fields

committed

protected volatile boolean committed
Field Value
Type Description
boolean

Methods

className()

protected String className()
Returns
Type Description
String

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
Name Description
documentReference DocumentReference

The DocumentReference to create.

pojo Object

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

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to create.

fields Map<String,Object>

A map of the fields and values for the document.

Returns
Type Description
T

The instance for chaining.

delete(DocumentReference documentReference)

public T delete(DocumentReference documentReference)

Deletes the document referred to by this DocumentReference.

Parameter
Name Description
documentReference DocumentReference

The DocumentReference to delete.

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to delete.

precondition Precondition

Precondition for the delete operation.

Returns
Type Description
T

The instance for chaining.

getMutationsSize()

public int getMutationsSize()

Get the number of writes.

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to overwrite.

pojo Object

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

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to overwrite.

pojo Object

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

options SetOptions

An object to configure the set behavior.

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to overwrite.

fields Map<String,Object>

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

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to overwrite.

fields Map<String,Object>

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

options SetOptions

An object to configure the set behavior.

Returns
Type Description
T

The instance for chaining.

toString()

public String toString()
Returns
Type Description
String
Overrides

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
Name Description
documentReference DocumentReference

The DocumentReference to update.

fieldPath FieldPath

The first field to set.

value Object

The first value to set.

moreFieldsAndValues Object[]

String and Object pairs with more fields to be set.

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to update.

precondition Precondition

Precondition to enforce on this update.

fieldPath FieldPath

The first field to set.

value Object

The first value to set.

moreFieldsAndValues Object[]

String and Object pairs with more fields to be set.

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to update.

precondition Precondition

Precondition to enforce on this update.

field String

The first field to set.

value Object

The first value to set.

moreFieldsAndValues Object[]

String and Object pairs with more fields to be set.

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to update.

field String

The first field to set.

value Object

The first value to set.

moreFieldsAndValues Object[]

String and Object pairs with more fields to be set.

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to update.

fields Map<String,Object>

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

Returns
Type Description
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
Name Description
documentReference DocumentReference

The DocumentReference to update.

fields Map<String,Object>

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

precondition Precondition

Precondition to enforce on this update.

Returns
Type Description
T

The instance for chaining.