Package com.google.cloud.firestore
Class UpdateBuilder<T>
java.lang.Object
com.google.cloud.firestore.UpdateBuilder<T>
- Direct Known Subclasses:
Transaction
,WriteBatch
Abstract class that collects and bundles all write operations for
Transaction
and WriteBatch
.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(DocumentReference documentReference, Object pojo) Creates a new Document at the DocumentReference location.create
(DocumentReference documentReference, Map<String, Object> fields) Creates a new Document at the DocumentReference's location.delete
(DocumentReference documentReference) Deletes the document referred to by this DocumentReference.delete
(DocumentReference documentReference, Precondition precondition) Deletes the document referred to by this DocumentReference.int
Get the number of writes.set
(DocumentReference documentReference, Object pojo) Overwrites the document referred to by this DocumentReference.set
(DocumentReference documentReference, Object pojo, SetOptions options) Overwrites the document referred to by this DocumentReference.set
(DocumentReference documentReference, Map<String, Object> fields) Overwrites the document referred to by this DocumentReference.set
(DocumentReference documentReference, Map<String, Object> fields, SetOptions options) Overwrites the document referred to by this DocumentReference.toString()
update
(DocumentReference documentReference, FieldPath fieldPath, Object value, Object... moreFieldsAndValues) Updates the fields in the document referred to by this DocumentReference.update
(DocumentReference documentReference, Precondition precondition, FieldPath fieldPath, Object value, Object... moreFieldsAndValues) Updates the fields in the document referred to by this DocumentReference.update
(DocumentReference documentReference, Precondition precondition, String field, Object value, Object... moreFieldsAndValues) Updates the fields in the document referred to by this DocumentReference.update
(DocumentReference documentReference, String field, Object value, Object... moreFieldsAndValues) Updates the fields in the document referred to by this DocumentReference.update
(DocumentReference documentReference, Map<String, Object> fields) Updates fields in the document referred to by this DocumentReference.update
(DocumentReference documentReference, Map<String, Object> fields, Precondition precondition) Updates fields in the document referred to by this DocumentReference.
-
Field Details
-
committed
protected boolean committed
-
-
Method Details
-
create
@Nonnull public T create(@Nonnull DocumentReference documentReference, @Nonnull Map<String, Object> fields) Creates a new Document at the DocumentReference's location. It fails the write if the document exists.- Parameters:
documentReference
- The DocumentReference to create.fields
- A map of the fields and values for the document.- Returns:
- The instance for chaining.
-
create
Creates a new Document at the DocumentReference location. It fails the write if the document exists.- Parameters:
documentReference
- The DocumentReference to create.pojo
- The POJO that will be used to populate the document contents.- Returns:
- The instance for chaining.
-
set
@Nonnull public T set(@Nonnull DocumentReference documentReference, @Nonnull 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:
documentReference
- The DocumentReference to overwrite.fields
- A map of the field paths and values for the document.- Returns:
- The instance for chaining.
-
set
@Nonnull public T set(@Nonnull DocumentReference documentReference, @Nonnull Map<String, Object> fields, @Nonnull SetOptions options) Overwrites the document referred to by this DocumentReference. If the document doesn't exist yet, it will be created. If you passSetOptions
, the provided data can be merged into an existing document.- Parameters:
documentReference
- The DocumentReference to overwrite.fields
- A map of the field paths and values for the document.options
- An object to configure the set behavior.- Returns:
- The instance for chaining.
-
set
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:
documentReference
- The DocumentReference to overwrite.pojo
- The POJO that will be used to populate the document contents.- Returns:
- The instance for chaining.
-
set
@Nonnull public T set(@Nonnull DocumentReference documentReference, @Nonnull Object pojo, @Nonnull SetOptions options) Overwrites the document referred to by this DocumentReference. If the document doesn't exist yet, it will be created. If you passSetOptions
, the provided data can be merged into an existing document.- Parameters:
documentReference
- The DocumentReference to overwrite.pojo
- The POJO that will be used to populate the document contents.options
- An object to configure the set behavior.- Returns:
- The instance for chaining.
-
update
@Nonnull public T update(@Nonnull DocumentReference documentReference, @Nonnull 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:
documentReference
- The DocumentReference to update.fields
- A Map containing the fields and values with which to update the document.- Returns:
- The instance for chaining.
-
update
@Nonnull public T update(@Nonnull DocumentReference documentReference, @Nonnull 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:
documentReference
- The DocumentReference to update.fields
- A Map containing the fields and values with which to update the document.precondition
- Precondition to enforce on this update.- Returns:
- The instance for chaining.
-
update
@Nonnull public T update(@Nonnull DocumentReference documentReference, @Nonnull String field, @Nullable 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:
documentReference
- The DocumentReference to update.field
- The first field to set.value
- The first value to set.moreFieldsAndValues
- String and Object pairs with more fields to be set.- Returns:
- The instance for chaining.
-
update
@Nonnull public T update(@Nonnull DocumentReference documentReference, @Nonnull FieldPath fieldPath, @Nullable 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:
documentReference
- The DocumentReference to update.fieldPath
- The first field to set.value
- The first value to set.moreFieldsAndValues
- String and Object pairs with more fields to be set.- Returns:
- The instance for chaining.
-
update
@Nonnull public T update(@Nonnull DocumentReference documentReference, @Nonnull Precondition precondition, @Nonnull String field, @Nullable 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:
documentReference
- The DocumentReference to update.precondition
- Precondition to enforce on this update.field
- The first field to set.value
- The first value to set.moreFieldsAndValues
- String and Object pairs with more fields to be set.- Returns:
- The instance for chaining.
-
update
@Nonnull public T update(@Nonnull DocumentReference documentReference, @Nonnull Precondition precondition, @Nonnull FieldPath fieldPath, @Nullable 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:
documentReference
- The DocumentReference to update.precondition
- Precondition to enforce on this update.fieldPath
- The first field to set.value
- The first value to set.moreFieldsAndValues
- String and Object pairs with more fields to be set.- Returns:
- The instance for chaining.
-
delete
@Nonnull public T delete(@Nonnull DocumentReference documentReference, @Nonnull Precondition precondition) Deletes the document referred to by this DocumentReference.- Parameters:
documentReference
- The DocumentReference to delete.precondition
- Precondition for the delete operation.- Returns:
- The instance for chaining.
-
delete
Deletes the document referred to by this DocumentReference.- Parameters:
documentReference
- The DocumentReference to delete.- Returns:
- The instance for chaining.
-
getMutationsSize
public int getMutationsSize()Get the number of writes. -
toString
-