firebase::firestore::SetOptions

#include <set_options.h>

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

Summary

By providing theSetOptions objects returned byMerge(), the Set() methods inDocumentReference,WriteBatch andTransaction can be configured to perform granular merges instead of overwriting the target documents in their entirety.

Constructors and Destructors

SetOptions()
CreatesSetOptions with overwrite semantics.
SetOptions(constSetOptions & other)
Copy constructor.
SetOptions(SetOptions && other)
Move constructor.
~SetOptions()

Public types

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

Public functions

operator=(constSetOptions & 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 ofSetOptions.

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

CreatesSetOptions with overwrite semantics.

SetOptions

SetOptions(constSetOptions&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 forSetOptions. After being moved from,SetOptions is in a valid but unspecified state.

Details
Parameters
other
SetOptions to move data from.

operator=

SetOptions&operator=(constSetOptions&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 destinationSetOptions.

operator=

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

Move assignment operator.

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

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

~SetOptions

~SetOptions()

Public static functions

Merge

SetOptionsMerge()

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

SetOptionsMergeFieldPaths(conststd::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 infields is ignored and remains untouched.

It is an error to pass aSetOptions 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

SetOptionsMergeFields(conststd::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 infields is ignored and remains untouched.

It is an error to pass aSetOptions 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.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-01-23 UTC.