SetOptions

public final class SetOptions


An options object that configures the behavior of set() calls. By providing one of the SetOptions objects returned by merge, mergeFields and mergeFieldPaths, the set() calls in DocumentReference, WriteBatch and Transaction can be configured to perform granular merges instead of overwriting the target documents in their entirety.

Summary

Public fields

final @Nullable FieldMask

Public methods

boolean
int
static @NonNull SetOptions

Changes the behavior of set() calls to only replace the values specified in its data argument.

static @NonNull SetOptions

Changes the behavior of set() calls to only replace the given fields.

static @NonNull SetOptions
mergeFields(String[] fields)

Changes the behavior of set() calls to only replace the given fields.

static @NonNull SetOptions

Changes the behavior of set() calls to only replace the given fields.

Public fields

fieldMask

public final @Nullable FieldMask fieldMask

Public methods

equals

public boolean equals(Object o)

hashCode

public int hashCode()

merge

public static @NonNull SetOptions merge()

Changes the behavior of set() calls to only replace the values specified in its data argument. Fields omitted from the set() call will remain untouched. If your input sets any field to an empty map, all nested fields are overwritten.

mergeFieldPaths

public static @NonNull SetOptions mergeFieldPaths(@NonNull List<FieldPath> fields)

Changes the behavior of set() calls to only replace the given fields. Any field that is not specified in fields is ignored and remains untouched.

It is an error to pass a SetOptions object to a set() call that is missing a value for any of the fields specified here in its to data argument.

Parameters
@NonNull List<FieldPath> fields

The list of fields to merge.

mergeFields

public static @NonNull SetOptions mergeFields(String[] fields)

Changes the behavior of set() calls to only replace the given fields. Any field that is not specified in fields is ignored and remains untouched.

It is an error to pass a SetOptions object to a set() call that is missing a value for any of the fields specified here.

Parameters
String[] fields

The list of fields to merge. Fields can contain dots to reference nested fields within the document.

mergeFields

public static @NonNull SetOptions mergeFields(@NonNull List<String> fields)

Changes the behavior of set() calls to only replace the given fields. Any field that is not specified in fields is ignored and remains untouched. If your input sets any field to an empty map, all nested fields are overwritten.

It is an error to pass a SetOptions object to a set() call that is missing a value for any of the fields specified here.

Parameters
@NonNull List<String> fields

The list of fields to merge. Fields can contain dots to reference nested fields within the document.