aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-04-15 13:06:06 -0700
committerGravatar GitHub <noreply@github.com>2018-04-15 13:06:06 -0700
commit5368c9e22f9a6b427466e9422645d688953013c0 (patch)
tree96ce766691fb24ffc0382cac472945b2190ecabe /Firestore/Example
parent33b12f6c70729d56c6e6350d435559cec1c44c61 (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/Example')
-rw-r--r--Firestore/Example/SwiftBuildTest/main.swift14
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm8
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRValidationTests.mm6
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm7
-rw-r--r--Firestore/Example/Tests/Integration/FSTTransactionTests.mm7
5 files changed, 20 insertions, 22 deletions
diff --git a/Firestore/Example/SwiftBuildTest/main.swift b/Firestore/Example/SwiftBuildTest/main.swift
index 555a75b..ad6c0f6 100644
--- a/Firestore/Example/SwiftBuildTest/main.swift
+++ b/Firestore/Example/SwiftBuildTest/main.swift
@@ -118,8 +118,16 @@ func writeDocument(at docRef: DocumentReference) {
print("Set complete!")
}
- // SetOptions
- docRef.setData(setData, options: SetOptions.merge())
+ // merge
+ docRef.setData(setData, merge: true)
+ docRef.setData(setData, merge: true) { error in
+ if let error = error {
+ print("Uh oh! \(error)")
+ return
+ }
+
+ print("Set complete!")
+ }
docRef.updateData(updateData)
docRef.delete()
@@ -156,6 +164,7 @@ func writeDocuments(at docRef: DocumentReference, database db: Firestore) {
batch = db.batch()
batch.setData(["a": "b"], forDocument: docRef)
+ batch.setData(["a": "b"], forDocument: docRef, merge: true)
batch.setData(["c": "d"], forDocument: docRef)
// commit without completion callback.
batch.commit()
@@ -355,7 +364,6 @@ func types() {
let _: QueryListenOptions
let _: Query
let _: QuerySnapshot
- let _: SetOptions
let _: SnapshotMetadata
let _: Transaction
let _: WriteBatch
diff --git a/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm b/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm
index 503d50b..9b6febe 100644
--- a/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm
@@ -144,7 +144,7 @@
[self expectationWithDescription:@"testCanMergeDataWithAnExistingDocumentUsingSet"];
[doc setData:mergeData
- options:[FIRSetOptions merge]
+ merge:YES
completion:^(NSError *error) {
XCTAssertNil(error);
[completed fulfill];
@@ -171,7 +171,7 @@
[self expectationWithDescription:@"testCanMergeDataWithAnExistingDocumentUsingSet"];
[doc setData:mergeData
- options:[FIRSetOptions merge]
+ merge:YES
completion:^(NSError *error) {
XCTAssertNil(error);
[completed fulfill];
@@ -203,7 +203,7 @@
[self expectationWithDescription:@"testCanMergeDataWithAnExistingDocumentUsingSet"];
[doc setData:mergeData
- options:[FIRSetOptions merge]
+ merge:YES
completion:^(NSError *error) {
XCTAssertNil(error);
[completed fulfill];
@@ -244,7 +244,7 @@
[self expectationWithDescription:@"testCanMergeDataWithAnExistingDocumentUsingSet"];
[doc setData:mergeData
- options:[FIRSetOptions merge]
+ merge:YES
completion:^(NSError *error) {
XCTAssertNil(error);
[completed fulfill];
diff --git a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
index 82c57c3..2c6a2a8 100644
--- a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
@@ -282,7 +282,7 @@
[self expectSet:@{@"foo" : [FIRFieldValue fieldValueForDelete]}
toFailWithReason:
@"FieldValue.delete() can only be used with updateData() and setData() with "
- @"SetOptions.merge() (found in field foo)"];
+ @"merge:true (found in field foo)"];
}
- (void)testUpdatesWithNestedFieldValueDeleteFail {
@@ -304,7 +304,7 @@
FIRDocumentReference *badRef = [db2 documentWithPath:@"foo/bar"];
FIRWriteBatch *batch = [db1 batch];
FSTAssertThrows([batch setData:data forDocument:badRef], reason);
- FSTAssertThrows([batch setData:data forDocument:badRef options:[FIRSetOptions merge]], reason);
+ FSTAssertThrows([batch setData:data forDocument:badRef merge:YES], reason);
FSTAssertThrows([batch updateData:data forDocument:badRef], reason);
FSTAssertThrows([batch deleteDocument:badRef], reason);
}
@@ -322,7 +322,7 @@
[db1 runTransactionWithBlock:^id(FIRTransaction *txn, NSError **pError) {
FSTAssertThrows([txn getDocument:badRef error:nil], reason);
FSTAssertThrows([txn setData:data forDocument:badRef], reason);
- FSTAssertThrows([txn setData:data forDocument:badRef options:[FIRSetOptions merge]], reason);
+ FSTAssertThrows([txn setData:data forDocument:badRef merge:YES], reason);
FSTAssertThrows([txn updateData:data forDocument:badRef], reason);
FSTAssertThrows([txn deleteDocument:badRef], reason);
return nil;
diff --git a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm
index b1d6738..3f2d64b 100644
--- a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm
@@ -79,12 +79,7 @@
XCTestExpectation *batchExpectation = [self expectationWithDescription:@"batch written"];
FIRWriteBatch *batch = [doc.firestore batch];
[batch setData:@{ @"a" : @"b", @"nested" : @{@"a" : @"b"} } forDocument:doc];
- [batch setData:@{
- @"c" : @"d",
- @"nested" : @{@"c" : @"d"}
- }
- forDocument:doc
- options:[FIRSetOptions merge]];
+ [batch setData:@{ @"c" : @"d", @"nested" : @{@"c" : @"d"} } forDocument:doc merge:YES];
[batch commitWithCompletion:^(NSError *error) {
XCTAssertNil(error);
[batchExpectation fulfill];
diff --git a/Firestore/Example/Tests/Integration/FSTTransactionTests.mm b/Firestore/Example/Tests/Integration/FSTTransactionTests.mm
index 2464b0c..999987b 100644
--- a/Firestore/Example/Tests/Integration/FSTTransactionTests.mm
+++ b/Firestore/Example/Tests/Integration/FSTTransactionTests.mm
@@ -203,12 +203,7 @@
XCTestExpectation *expectation = [self expectationWithDescription:@"transaction"];
[firestore runTransactionWithBlock:^id _Nullable(FIRTransaction *transaction, NSError **error) {
[transaction setData:@{ @"a" : @"b", @"nested" : @{@"a" : @"b"} } forDocument:doc];
- [transaction setData:@{
- @"c" : @"d",
- @"nested" : @{@"c" : @"d"}
- }
- forDocument:doc
- options:[FIRSetOptions merge]];
+ [transaction setData:@{ @"c" : @"d", @"nested" : @{@"c" : @"d"} } forDocument:doc merge:YES];
return @YES;
}
completion:^(id _Nullable result, NSError *_Nullable error) {