diff options
author | Gil <mcg@google.com> | 2018-04-15 13:06:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-15 13:06:06 -0700 |
commit | 5368c9e22f9a6b427466e9422645d688953013c0 (patch) | |
tree | 96ce766691fb24ffc0382cac472945b2190ecabe /Firestore/Source/Public | |
parent | 33b12f6c70729d56c6e6350d435559cec1c44c61 (diff) |
Replace the `SetOptions` object with a simple boolean. (#1098)
Instead of calling
`setData(["a": "b"], options: SetOptions.merge())`
call
`setData(["a": "b"], merge: true)`
Diffstat (limited to 'Firestore/Source/Public')
-rw-r--r-- | Firestore/Source/Public/FIRDocumentReference.h | 19 | ||||
-rw-r--r-- | Firestore/Source/Public/FIRSetOptions.h | 46 | ||||
-rw-r--r-- | Firestore/Source/Public/FIRTransaction.h | 11 | ||||
-rw-r--r-- | Firestore/Source/Public/FIRWriteBatch.h | 11 | ||||
-rw-r--r-- | Firestore/Source/Public/FirebaseFirestore.h | 1 |
5 files changed, 19 insertions, 69 deletions
diff --git a/Firestore/Source/Public/FIRDocumentReference.h b/Firestore/Source/Public/FIRDocumentReference.h index dd2d106..e7ba6eb 100644 --- a/Firestore/Source/Public/FIRDocumentReference.h +++ b/Firestore/Source/Public/FIRDocumentReference.h @@ -18,10 +18,9 @@ #import "FIRListenerRegistration.h" -@class FIRFirestore; @class FIRCollectionReference; @class FIRDocumentSnapshot; -@class FIRSetOptions; +@class FIRFirestore; NS_ASSUME_NONNULL_BEGIN @@ -82,14 +81,14 @@ NS_SWIFT_NAME(DocumentReference) /** * Writes to the document referred to by this DocumentReference. If the document does not yet - * exist, it will be created. If you pass `FIRSetOptions`, the provided data will be merged into - * an existing document. + * exist, it will be created. If you pass `merge:YES`, the provided data will be merged into + * any existing document. * * @param documentData An `NSDictionary` that contains the fields and data to write to the * document. - * @param options A `FIRSetOptions` used to configure the set behavior. + * @param merge Whether to merge the provided data into any existing document. */ -- (void)setData:(NSDictionary<NSString *, id> *)documentData options:(FIRSetOptions *)options; +- (void)setData:(NSDictionary<NSString *, id> *)documentData merge:(BOOL)merge; /** * Overwrites the document referred to by this `FIRDocumentReference`. If no document exists, it @@ -106,18 +105,18 @@ NS_SWIFT_NAME(DocumentReference) /** * Writes to the document referred to by this DocumentReference. If the document does not yet - * exist, it will be created. If you pass `FIRSetOptions`, the provided data will be merged into - * an existing document. + * exist, it will be created. If you pass `merge:YES`, the provided data will be merged into + * any existing document. * * @param documentData An `NSDictionary` containing the fields that make up the document * to be written. - * @param options A `FIRSetOptions` used to configure the set behavior. + * @param merge Whether to merge the provided data into any existing document. * @param completion A block to execute once the document has been successfully written to the * server. This block will not be called while the client is offline, though local * changes will be visible immediately. */ - (void)setData:(NSDictionary<NSString *, id> *)documentData - options:(FIRSetOptions *)options + merge:(BOOL)merge completion:(nullable void (^)(NSError *_Nullable error))completion; /** diff --git a/Firestore/Source/Public/FIRSetOptions.h b/Firestore/Source/Public/FIRSetOptions.h deleted file mode 100644 index c865e06..0000000 --- a/Firestore/Source/Public/FIRSetOptions.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2017 Google - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#import <Foundation/Foundation.h> - -NS_ASSUME_NONNULL_BEGIN - -/** - * An options object that configures the behavior of setData() calls. By providing the - * `FIRSetOptions` objects returned by `merge:`, the setData() methods in `FIRDocumentReference`, - * `FIRWriteBatch` and `FIRTransaction` can be configured to perform granular merges instead - * of overwriting the target documents in their entirety. - */ -NS_SWIFT_NAME(SetOptions) -@interface FIRSetOptions : NSObject - -/** */ -- (id)init NS_UNAVAILABLE; -/** - * Changes the behavior of setData() calls to only replace the values specified in its data - * argument. Fields with no corresponding values in the data passed to setData() will remain - * untouched. - * - * @return The created `FIRSetOptions` object - */ -+ (instancetype)merge; - -/** Whether setData() should merge existing data instead of performing an overwrite. */ -@property(nonatomic, readonly, getter=isMerge) BOOL merge; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Firestore/Source/Public/FIRTransaction.h b/Firestore/Source/Public/FIRTransaction.h index 51a6e90..2fa4430 100644 --- a/Firestore/Source/Public/FIRTransaction.h +++ b/Firestore/Source/Public/FIRTransaction.h @@ -20,7 +20,6 @@ NS_ASSUME_NONNULL_BEGIN @class FIRDocumentReference; @class FIRDocumentSnapshot; -@class FIRSetOptions; /** * `FIRTransaction` provides methods to read and write data within a transaction. @@ -50,19 +49,19 @@ NS_SWIFT_NAME(Transaction) /** * Writes to the document referred to by `document`. If the document doesn't yet exist, - * this method creates it and then sets the data. If you pass `FIRSetOptions`, the provided data - * will be merged into an existing document. + * this method creates it and then sets the data. If you pass `merge:YES`, the provided data will be + * merged into any existing document. * * @param data An `NSDictionary` that contains the fields and data to write to the document. * @param document A reference to the document whose data should be overwritten. - * @param options A `FIRSetOptions` used to configure the set behavior. + * @param merge Whether to merge the provided data into any existing document. * @return This `FIRTransaction` instance. Used for chaining method calls. */ // clang-format off - (FIRTransaction *)setData:(NSDictionary<NSString *, id> *)data forDocument:(FIRDocumentReference *)document - options:(FIRSetOptions *)options - NS_SWIFT_NAME(setData(_:forDocument:options:)); + merge:(BOOL)merge + NS_SWIFT_NAME(setData(_:forDocument:merge:)); // clang-format on /** diff --git a/Firestore/Source/Public/FIRWriteBatch.h b/Firestore/Source/Public/FIRWriteBatch.h index 8ff1bec..1568723 100644 --- a/Firestore/Source/Public/FIRWriteBatch.h +++ b/Firestore/Source/Public/FIRWriteBatch.h @@ -19,7 +19,6 @@ NS_ASSUME_NONNULL_BEGIN @class FIRDocumentReference; -@class FIRSetOptions; /** * A write batch is used to perform multiple writes as a single atomic unit. @@ -53,19 +52,19 @@ NS_SWIFT_NAME(WriteBatch) /** * Writes to the document referred to by `document`. If the document doesn't yet exist, - * this method creates it and then sets the data. If you pass `FIRSetOptions`, the provided data - * will be merged into an existing document. + * this method creates it and then sets the data. If you pass `merge:YES`, the provided data will be + * merged into any existing document. * * @param data An `NSDictionary` that contains the fields and data to write to the document. * @param document A reference to the document whose data should be overwritten. - * @param options A `FIRSetOptions` used to configure the set behavior. + * @param merge Whether to merge the provided data into any existing document. * @return This `FIRWriteBatch` instance. Used for chaining method calls. */ // clang-format off - (FIRWriteBatch *)setData:(NSDictionary<NSString *, id> *)data forDocument:(FIRDocumentReference *)document - options:(FIRSetOptions *)options - NS_SWIFT_NAME(setData(_:forDocument:options:)); + merge:(BOOL)merge + NS_SWIFT_NAME(setData(_:forDocument:merge:)); // clang-format on /** diff --git a/Firestore/Source/Public/FirebaseFirestore.h b/Firestore/Source/Public/FirebaseFirestore.h index 36f9fb7..127c935 100644 --- a/Firestore/Source/Public/FirebaseFirestore.h +++ b/Firestore/Source/Public/FirebaseFirestore.h @@ -27,7 +27,6 @@ #import "FIRListenerRegistration.h" #import "FIRQuery.h" #import "FIRQuerySnapshot.h" -#import "FIRSetOptions.h" #import "FIRSnapshotMetadata.h" #import "FIRTimestamp.h" #import "FIRTransaction.h" |