firebase::firestore::SetOptions

#include <set_options.h>

An options object that configures the behavior of Set() calls.

Summary

By providing the SetOptions objects returned by Merge(), the Set() methods in DocumentReference, WriteBatch and Transaction can be configured to perform granular merges instead of overwriting the target documents in their entirety.

Constructors and Destructors

SetOptions()
Creates SetOptions with overwrite semantics.
SetOptions(const SetOptions & other)
Copy constructor.
SetOptions(SetOptions && other)
Move constructor.
~SetOptions()

Public types

Type{
  kOverwrite,
  kMergeAll,
  kMergeSpecific
}
enum
The enumeration of all types of SetOptions.

Public functions

operator=(const SetOptions & other)=default
Copy assignment operator.
operator=(SetOptions && other)=default
Move assignment operator.

Public static functions

Merge()
Returns an instance that can be used to change the behavior of Set() calls to only replace the values specified in its data argument.
MergeFieldPaths(const std::vector< FieldPath > & fields)
Returns an instance that can be used to change the behavior of Set() calls to only replace the given fields.
MergeFields(const std::vector< std::string > & fields)
Returns an instance that can be used to change the behavior of Set() calls to only replace the given fields.

Public types

Type

 Type

The enumeration of all types of SetOptions.

Properties
kMergeAll

Replaces the values specified in the call parameter while leaves omitted fields untouched.

kMergeSpecific

Replaces the values of the fields explicitly specified in the call parameter.

kOverwrite

Overwrites the whole document.

Public functions

SetOptions

 SetOptions()=default

Creates SetOptions with overwrite semantics.

SetOptions

 SetOptions(
  const SetOptions & other
)=default

Copy constructor.

This performs a deep copy, creating an independent instance.

Details
Parameters
other
SetOptions to copy from.

SetOptions

 SetOptions(
  SetOptions && other
)=default

Move constructor.

Moving is more efficient than copying for SetOptions. After being moved from, SetOptions is in a valid but unspecified state.

Details
Parameters
other
SetOptions to move data from.

operator=

SetOptions & operator=(
  const SetOptions & other
)=default

Copy assignment operator.

This performs a deep copy, creating an independent instance.

Details
Parameters
other
SetOptions to copy from.
Returns
Reference to the destination SetOptions.

operator=

SetOptions & operator=(
  SetOptions && other
)=default

Move assignment operator.

Moving is more efficient than copying for SetOptions. After being moved from, SetOptions is in a valid but unspecified state.

Details
Parameters
other
SetOptions to move data from.
Returns
Reference to the destination SetOptions.

~SetOptions

 ~SetOptions()

Public static functions

Merge

SetOptions Merge()

Returns an instance that can be used to change the behavior of Set() calls to only replace the values specified in its data argument.

Fields omitted from the Set() call will remain untouched.

MergeFieldPaths

SetOptions MergeFieldPaths(
  const std::vector< FieldPath > & fields
)

Returns an instance that can be used to change 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.

Details
Parameters
fields
The list of fields to merge.

MergeFields

SetOptions MergeFields(
  const std::vector< std::string > & fields
)

Returns an instance that can be used to change 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.

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