Skip to content

Commit 17245b4

Browse files
Improve documentation for merge behavior (#9121)
1 parent 0feef36 commit 17245b4

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

Firestore/Source/Public/FirebaseFirestore/FIRDocumentReference.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ NS_SWIFT_NAME(DocumentReference)
9090
*
9191
* @param documentData An `NSDictionary` that contains the fields and data to write to the
9292
* document.
93-
* @param merge Whether to merge the provided data into any existing document.
93+
* @param merge Whether to merge the provided data into any existing document. If enabled,
94+
* all omitted fields remain untouched. If your input sets any field to an empty dictionary, any
95+
* nested field at this location is overwritten.
9496
*/
9597
- (void)setData:(NSDictionary<NSString *, id> *)documentData merge:(BOOL)merge;
9698

@@ -106,8 +108,9 @@ NS_SWIFT_NAME(DocumentReference)
106108
* @param documentData An `NSDictionary` containing the fields that make up the document
107109
* to be written.
108110
* @param mergeFields An `NSArray` that contains a list of `NSString` or `FIRFieldPath` elements
109-
* specifying which fields to merge. Fields can contain dots to reference nested fields within
110-
* the document.
111+
* specifying which fields to merge. Fields can contain dots to reference nested fields within
112+
* the document. If your input sets any field to an empty dictionary, any nested field at this
113+
* location is overwritten.
111114
*/
112115
- (void)setData:(NSDictionary<NSString *, id> *)documentData mergeFields:(NSArray<id> *)mergeFields;
113116

Firestore/Source/Public/FirebaseFirestore/FIRTransaction.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ NS_SWIFT_NAME(Transaction)
5454
*
5555
* @param data An `NSDictionary` that contains the fields and data to write to the document.
5656
* @param document A reference to the document whose data should be overwritten.
57-
* @param merge Whether to merge the provided data into any existing document.
57+
* @param merge Whether to merge the provided data into any existing document. If enabled,
58+
* all omitted fields remain untouched. If your input sets any field to an empty dictionary, any
59+
* nested field at this location is overwritten.
5860
* @return This `FIRTransaction` instance. Used for chaining method calls.
5961
*/
6062
// clang-format off
@@ -77,8 +79,9 @@ NS_SWIFT_NAME(Transaction)
7779
* to be written.
7880
* @param document A reference to the document whose data should be overwritten.
7981
* @param mergeFields An `NSArray` that contains a list of `NSString` or `FIRFieldPath` elements
80-
* specifying which fields to merge. Fields can contain dots to reference nested fields within
81-
* the document.
82+
* specifying which fields to merge. Fields can contain dots to reference nested fields within
83+
* the document. If your input sets any field to an empty dictionary, any nested field at this
84+
* llocation is overwritten.
8285
* @return This `FIRTransaction` instance. Used for chaining method calls.
8386
*/
8487
// clang-format off

Firestore/Source/Public/FirebaseFirestore/FIRWriteBatch.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ NS_SWIFT_NAME(WriteBatch)
5757
*
5858
* @param data An `NSDictionary` that contains the fields and data to write to the document.
5959
* @param document A reference to the document whose data should be overwritten.
60-
* @param merge Whether to merge the provided data into any existing document.
60+
* @param merge Whether to merge the provided data into any existing document. If enabled,
61+
* all omitted fields remain untouched. If your input sets any field to an empty dictionary, any
62+
* nested field at this location is overwritten.
6163
* @return This `FIRWriteBatch` instance. Used for chaining method calls.
6264
*/
6365
// clang-format off
@@ -79,8 +81,9 @@ NS_SWIFT_NAME(WriteBatch)
7981
* @param data An `NSDictionary` that contains the fields and data to write to the document.
8082
* @param document A reference to the document whose data should be overwritten.
8183
* @param mergeFields An `NSArray` that contains a list of `NSString` or `FIRFieldPath` elements
82-
* specifying which fields to merge. Fields can contain dots to reference nested fields within
83-
* the document.
84+
* specifying which fields to merge. Fields can contain dots to reference nested fields within
85+
* the document. If your input sets any field to an empty dictionary, any nested field at this
86+
* location is overwritten.
8487
* @return This `FIRWriteBatch` instance. Used for chaining method calls.
8588
*/
8689
// clang-format off

0 commit comments

Comments
 (0)