aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Michael Lehenbauer <mikelehen@gmail.com>2018-04-20 14:48:59 -0700
committerGravatar GitHub <noreply@github.com>2018-04-20 14:48:59 -0700
commit7dca635039efb00082624552c223ac7f47ea0cad (patch)
tree4a031dcb31dcfd04c1b43f83e956a440d875fbb0
parent11b6c014fb8799b8eff1acf795e7d4c366ea029e (diff)
Move array transforms to internal header pending backend support. (#1139)
-rw-r--r--Firestore/CHANGELOG.md4
-rw-r--r--Firestore/Example/SwiftBuildTest/main.swift5
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm2
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRValidationTests.mm2
-rw-r--r--Firestore/Example/Tests/Model/FSTMutationTests.mm1
-rw-r--r--Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm1
-rw-r--r--Firestore/Source/API/FIRFieldValue+Internal.h28
-rw-r--r--Firestore/Source/Public/FIRFieldValue.h23
8 files changed, 37 insertions, 29 deletions
diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md
index 77d823a..5543325 100644
--- a/Firestore/CHANGELOG.md
+++ b/Firestore/CHANGELOG.md
@@ -1,8 +1,4 @@
# Unreleased
-- [feature] Added FieldValue.arrayUnion() and FieldValue.arrayRemove() methods
- which can be used inside setData() or updateData() calls to atomically add
- or remove specific elements to an array field in a document without using a
- transaction.
- [changed] Replaced the `DocumentListenOptions` object with a simple boolean.
Instead of calling
`addSnapshotListener(options: DocumentListenOptions.includeMetadataChanges(true))`
diff --git a/Firestore/Example/SwiftBuildTest/main.swift b/Firestore/Example/SwiftBuildTest/main.swift
index f61da2b..f04de5b 100644
--- a/Firestore/Example/SwiftBuildTest/main.swift
+++ b/Firestore/Example/SwiftBuildTest/main.swift
@@ -103,8 +103,9 @@ func writeDocument(at docRef: DocumentReference) {
"bar.baz": 42,
FieldPath(["foobar"]): 42,
"server_timestamp": FieldValue.serverTimestamp(),
- "array_union": FieldValue.arrayUnion(["a", "b"]),
- "array_remove": FieldValue.arrayRemove(["a", "b"]),
+ // TODO(array-features): Uncomment once we add these to the public API
+ // "array_union": FieldValue.arrayUnion(["a", "b"]),
+ // "array_remove": FieldValue.arrayRemove(["a", "b"]),
"field_delete": FieldValue.delete(),
] as [AnyHashable: Any]
diff --git a/Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm b/Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm
index 5f0cf92..1c82461 100644
--- a/Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm
@@ -18,6 +18,8 @@
#import <XCTest/XCTest.h>
+#import "Firestore/Source/API/FIRFieldValue+Internal.h"
+
#import "Firestore/Example/Tests/Util/FSTEventAccumulator.h"
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
diff --git a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
index 2361fd0..ee0f386 100644
--- a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
@@ -18,6 +18,8 @@
#import <XCTest/XCTest.h>
+#import "Firestore/Source/API/FIRFieldValue+Internal.h"
+
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
diff --git a/Firestore/Example/Tests/Model/FSTMutationTests.mm b/Firestore/Example/Tests/Model/FSTMutationTests.mm
index 3183efd..936bd38 100644
--- a/Firestore/Example/Tests/Model/FSTMutationTests.mm
+++ b/Firestore/Example/Tests/Model/FSTMutationTests.mm
@@ -22,6 +22,7 @@
#include <vector>
+#import "Firestore/Source/API/FIRFieldValue+Internal.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
diff --git a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
index 8ddddb0..8d62b4d 100644
--- a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
+++ b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
@@ -35,6 +35,7 @@
#import "Firestore/Protos/objc/google/firestore/v1beta1/Write.pbobjc.h"
#import "Firestore/Protos/objc/google/rpc/Status.pbobjc.h"
#import "Firestore/Protos/objc/google/type/Latlng.pbobjc.h"
+#import "Firestore/Source/API/FIRFieldValue+Internal.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
#import "Firestore/Source/Local/FSTQueryData.h"
diff --git a/Firestore/Source/API/FIRFieldValue+Internal.h b/Firestore/Source/API/FIRFieldValue+Internal.h
index 1618cd4..883a307 100644
--- a/Firestore/Source/API/FIRFieldValue+Internal.h
+++ b/Firestore/Source/API/FIRFieldValue+Internal.h
@@ -54,4 +54,32 @@ NS_ASSUME_NONNULL_BEGIN
@property(strong, nonatomic, readonly) NSArray<id> *elements;
@end
+// TODO(array-features): Move to FIRFieldValue.h once backend support lands.
+@interface FIRFieldValue ()
+
+/**
+ * Returns a special value that can be used with setData() or updateData() that tells the server to
+ * union the given elements with any array value that already exists on the server. Each
+ * specified element that doesn't already exist in the array will be added to the end. If the
+ * field being modified is not already an array it will be overwritten with an array containing
+ * exactly the specified elements.
+ *
+ * @param elements The elements to union into the array.
+ * @return The FieldValue sentinel for use in a call to setData() or updateData().
+ */
++ (instancetype)fieldValueForArrayUnion:(NSArray<id> *)elements NS_SWIFT_NAME(arrayUnion(_:));
+
+/**
+ * Returns a special value that can be used with setData() or updateData() that tells the server to
+ * remove the given elements from any array value that already exists on the server. All
+ * instances of each element specified will be removed from the array. If the field being
+ * modified is not already an array it will be overwritten with an empty array.
+ *
+ * @param elements The elements to remove from the array.
+ * @return The FieldValue sentinel for use in a call to setData() or updateData().
+ */
++ (instancetype)fieldValueForArrayRemove:(NSArray<id> *)elements NS_SWIFT_NAME(arrayRemove(_:));
+
+@end
+
NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Public/FIRFieldValue.h b/Firestore/Source/Public/FIRFieldValue.h
index d896587..11a0da0 100644
--- a/Firestore/Source/Public/FIRFieldValue.h
+++ b/Firestore/Source/Public/FIRFieldValue.h
@@ -38,29 +38,6 @@ NS_SWIFT_NAME(FieldValue)
*/
+ (instancetype)fieldValueForServerTimestamp NS_SWIFT_NAME(serverTimestamp());
-/**
- * Returns a special value that can be used with setData() or updateData() that tells the server to
- * union the given elements with any array value that already exists on the server. Each
- * specified element that doesn't already exist in the array will be added to the end. If the
- * field being modified is not already an array it will be overwritten with an array containing
- * exactly the specified elements.
- *
- * @param elements The elements to union into the array.
- * @return The FieldValue sentinel for use in a call to setData() or updateData().
- */
-+ (instancetype)fieldValueForArrayUnion:(NSArray<id> *)elements NS_SWIFT_NAME(arrayUnion(_:));
-
-/**
- * Returns a special value that can be used with setData() or updateData() that tells the server to
- * remove the given elements from any array value that already exists on the server. All
- * instances of each element specified will be removed from the array. If the field being
- * modified is not already an array it will be overwritten with an empty array.
- *
- * @param elements The elements to remove from the array.
- * @return The FieldValue sentinel for use in a call to setData() or updateData().
- */
-+ (instancetype)fieldValueForArrayRemove:(NSArray<id> *)elements NS_SWIFT_NAME(arrayRemove(_:));
-
@end
NS_ASSUME_NONNULL_END