From 5da88e4b9b5ce9d1aee8611d03946e19bdfa5b65 Mon Sep 17 00:00:00 2001 From: zxu Date: Thu, 7 Dec 2017 15:36:15 -0500 Subject: Implement NSPredicate-based query (#531) * implement queryFilteredUsingPredicate in FIRQuery; * add unit test and integration test for queryFilteredUsingPredicate; * project change of adding the FIRQueryTests.m file; * refactoring queryFilteredUsingPredicate to split logic into two helpers; --- Firestore/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) (limited to 'Firestore/CHANGELOG.md') diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index 0c5bcdc..e6ecf11 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -4,6 +4,7 @@ with persistence enabled. - [fixed] Addressed race condition during the teardown of idle streams (#490). +- [feature] Queries can now be created from an NSPredicate. # v0.9.3 - [changed] Improved performance loading documents matching a query. -- cgit v1.2.3 From 440014eb37be95491232ee6e519073bc2299eb90 Mon Sep 17 00:00:00 2001 From: zxu Date: Fri, 8 Dec 2017 09:22:56 -0500 Subject: make FIRDocumentListenOptions.includeMetadataChanges private (#540) * make FIRDocumentListenOptions.includeMetadataChanges private as discussed in Firestore API discussion, the name clashes creates confusion. Android SDK already not exposing the property; here change iOS SDK to match it. * update CHANGELOG --- Firestore/CHANGELOG.md | 2 ++ Firestore/Source/API/FIRDocumentReference.m | 2 ++ Firestore/Source/Public/FIRDocumentReference.h | 2 -- 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'Firestore/CHANGELOG.md') diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index e6ecf11..32cbbfc 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased - [changed] Firestore no longer has a direct dependency on FirebaseAuth. +- [changed] Removed the includeMetadataChanges property in FIRDocumentListenOptions + to avoid confusion with the factory method of the same name. - [fixed] Fixed a crash when using path names with international characters with persistence enabled. diff --git a/Firestore/Source/API/FIRDocumentReference.m b/Firestore/Source/API/FIRDocumentReference.m index 1c80ea9..6279b7c 100644 --- a/Firestore/Source/API/FIRDocumentReference.m +++ b/Firestore/Source/API/FIRDocumentReference.m @@ -48,6 +48,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithIncludeMetadataChanges:(BOOL)includeMetadataChanges NS_DESIGNATED_INITIALIZER; +@property(nonatomic, assign, readonly) BOOL includeMetadataChanges; + @end @implementation FIRDocumentListenOptions diff --git a/Firestore/Source/Public/FIRDocumentReference.h b/Firestore/Source/Public/FIRDocumentReference.h index 439e727..7fcc7a8 100644 --- a/Firestore/Source/Public/FIRDocumentReference.h +++ b/Firestore/Source/Public/FIRDocumentReference.h @@ -36,8 +36,6 @@ NS_SWIFT_NAME(DocumentListenOptions) - (instancetype)init; -@property(nonatomic, assign, readonly) BOOL includeMetadataChanges; - /** * Sets the includeMetadataChanges option which controls whether metadata-only changes (i.e. only * `FIRDocumentSnapshot.metadata` changed) should trigger snapshot events. Default is NO. -- cgit v1.2.3 From 54ba423c87d6e0a409e4fa3dc95cd81ca16b97f7 Mon Sep 17 00:00:00 2001 From: zxu Date: Mon, 11 Dec 2017 15:37:01 -0500 Subject: Revisit commit method in FIRWriteBatch (#541) * revisit FIRWriteBatch commit * make commitWithCompletion completion nullable; * add commit; * add unit test; * add swift build test for commit; * update CHANGELOG. --- Firestore/CHANGELOG.md | 1 + Firestore/Example/SwiftBuildTest/main.swift | 26 ++++++++++++++++++++++ .../Tests/Integration/API/FIRWriteBatchTests.m | 17 ++++++++++++++ Firestore/Source/API/FIRWriteBatch.m | 6 ++++- Firestore/Source/Public/FIRWriteBatch.h | 7 +++++- 5 files changed, 55 insertions(+), 2 deletions(-) (limited to 'Firestore/CHANGELOG.md') diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index 32cbbfc..1a8eb07 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -2,6 +2,7 @@ - [changed] Firestore no longer has a direct dependency on FirebaseAuth. - [changed] Removed the includeMetadataChanges property in FIRDocumentListenOptions to avoid confusion with the factory method of the same name. +- [changed] Added a commit method that takes no completion handler to FIRWriteBatch. - [fixed] Fixed a crash when using path names with international characters with persistence enabled. diff --git a/Firestore/Example/SwiftBuildTest/main.swift b/Firestore/Example/SwiftBuildTest/main.swift index bea8b56..475c1b2 100644 --- a/Firestore/Example/SwiftBuildTest/main.swift +++ b/Firestore/Example/SwiftBuildTest/main.swift @@ -27,6 +27,8 @@ func main() { writeDocument(at: documentRef); + writeDocuments(at: documentRef, database: db); + addDocument(to: collectionRef); readDocument(at: documentRef); @@ -129,6 +131,30 @@ func writeDocument(at docRef: DocumentReference) { } } +func writeDocuments(at docRef: DocumentReference, database db: Firestore) { + var batch: WriteBatch; + + batch = db.batch(); + batch.setData(["a" : "b"], forDocument:docRef); + batch.setData(["c" : "d"], forDocument:docRef); + // commit without completion callback. + batch.commit(); + print("Batch write without completion complete!"); + + batch = db.batch(); + batch.setData(["a" : "b"], forDocument:docRef); + batch.setData(["c" : "d"], forDocument:docRef); + // commit with completion callback via trailing closure syntax. + batch.commit() { error in + if let error = error { + print("Uh oh! \(error)"); + return; + } + print("Batch write callback complete!"); + } + print("Batch write with completion complete!"); +} + func addDocument(to collectionRef: CollectionReference) { collectionRef.addDocument(data: ["foo": 42]); diff --git a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m index 562c29f..23ae7bc 100644 --- a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m +++ b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m @@ -35,6 +35,23 @@ [self awaitExpectations]; } +- (void)testCommitWithoutCompletionHandler { + FIRDocumentReference *doc = [self documentRef]; + FIRWriteBatch *batch1 = [doc.firestore batch]; + [batch1 setData:@{@"aa" : @"bb"} forDocument:doc]; + [batch1 commitWithCompletion:nil]; + FIRDocumentSnapshot *snapshot1 = [self readDocumentForRef:doc]; + XCTAssertTrue(snapshot1.exists); + XCTAssertEqualObjects(snapshot1.data, @{@"aa" : @"bb"}); + + FIRWriteBatch *batch2 = [doc.firestore batch]; + [batch2 setData:@{@"cc" : @"dd"} forDocument:doc]; + [batch2 commit]; + FIRDocumentSnapshot *snapshot2 = [self readDocumentForRef:doc]; + XCTAssertTrue(snapshot2.exists); + XCTAssertEqualObjects(snapshot2.data, @{@"cc" : @"dd"}); +} + - (void)testSetDocuments { FIRDocumentReference *doc = [self documentRef]; XCTestExpectation *batchExpectation = [self expectationWithDescription:@"batch written"]; diff --git a/Firestore/Source/API/FIRWriteBatch.m b/Firestore/Source/API/FIRWriteBatch.m index b918a9a..b1cfa09 100644 --- a/Firestore/Source/API/FIRWriteBatch.m +++ b/Firestore/Source/API/FIRWriteBatch.m @@ -93,7 +93,11 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (void)commitWithCompletion:(void (^)(NSError *_Nullable error))completion { +- (void)commit { + [self commitWithCompletion:nil]; +} + +- (void)commitWithCompletion:(nullable void (^)(NSError *_Nullable error))completion { [self verifyNotCommitted]; self.committed = TRUE; [self.firestore.client writeMutations:self.mutations completion:completion]; diff --git a/Firestore/Source/Public/FIRWriteBatch.h b/Firestore/Source/Public/FIRWriteBatch.h index 5f0034c..8ff1bec 100644 --- a/Firestore/Source/Public/FIRWriteBatch.h +++ b/Firestore/Source/Public/FIRWriteBatch.h @@ -92,6 +92,11 @@ NS_SWIFT_NAME(WriteBatch) - (FIRWriteBatch *)deleteDocument:(FIRDocumentReference *)document NS_SWIFT_NAME(deleteDocument(_:)); +/** + * Commits all of the writes in this write batch as a single atomic unit. + */ +- (void)commit; + /** * Commits all of the writes in this write batch as a single atomic unit. * @@ -101,7 +106,7 @@ NS_SWIFT_NAME(WriteBatch) * completion handler will not be called when the device is offline, though local * changes will be visible immediately. */ -- (void)commitWithCompletion:(void (^)(NSError *_Nullable error))completion; +- (void)commitWithCompletion:(nullable void (^)(NSError *_Nullable error))completion; @end -- cgit v1.2.3 From 43774fec33adda895609ccd61d7c00e71d2396bb Mon Sep 17 00:00:00 2001 From: Gil Date: Mon, 11 Dec 2017 14:14:05 -0800 Subject: Update CHANGELOG for Firestore v0.9.4 (#556) --- Firestore/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Firestore/CHANGELOG.md') diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index 0c5bcdc..ae9f994 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -1,8 +1,9 @@ # Unreleased + +# v0.9.4 - [changed] Firestore no longer has a direct dependency on FirebaseAuth. - [fixed] Fixed a crash when using path names with international characters with persistence enabled. - - [fixed] Addressed race condition during the teardown of idle streams (#490). # v0.9.3 -- cgit v1.2.3