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 @NullableFieldMask

Public methods

boolean
int
static @NonNullSetOptions

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

static @NonNullSetOptions

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

static @NonNullSetOptions
mergeFields(String[] fields)

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

static @NonNullSetOptions

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

Public fields

fieldMask

public final @NullableFieldMask fieldMask

Public methods

equals

public boolean equals(Object o)

hashCode

public int hashCode()

merge

public static @NonNullSetOptions 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 @NonNullSetOptions mergeFieldPaths(@NonNullList<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
@NonNullList<FieldPath> fields

The list of fields to merge.

mergeFields

public static @NonNullSetOptions 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 @NonNullSetOptions mergeFields(@NonNullList<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
@NonNullList<String> fields

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