aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-04-16 13:50:11 -0700
committerGravatar GitHub <noreply@github.com>2018-04-16 13:50:11 -0700
commita25d05487435d397f3b8cd399ee8355eae497f0d (patch)
tree323b23f9ad4849093f2dbb53c8ebece59f0bd870
parent0ac71f294ffedc8c6a3fb93e18253ee25624ec00 (diff)
Replace the `SnapshotOptions` object with the behavior enum. (#1109)
Instead of calling `get(field, SnapshotOptions.serverTimestampBehavior(.estimate))` call `get(field, serverTimestampBehavior: .estimate)`
-rw-r--r--Firestore/CHANGELOG.md4
-rw-r--r--Firestore/Example/SwiftBuildTest/main.swift6
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm58
-rw-r--r--Firestore/Source/API/FIRDocumentSnapshot.mm57
-rw-r--r--Firestore/Source/API/FIRSnapshotOptions+Internal.h38
-rw-r--r--Firestore/Source/API/FIRSnapshotOptions.mm72
-rw-r--r--Firestore/Source/Model/FSTFieldValue.h5
-rw-r--r--Firestore/Source/Model/FSTFieldValue.mm24
-rw-r--r--Firestore/Source/Public/FIRDocumentSnapshot.h49
9 files changed, 93 insertions, 220 deletions
diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md
index 4761a62..e17cf56 100644
--- a/Firestore/CHANGELOG.md
+++ b/Firestore/CHANGELOG.md
@@ -16,6 +16,10 @@
- [changed] Replaced the `SetOptions` object with a simple boolean. Instead of
calling `setData(["a": "b"], options: SetOptions.merge())` call
`setData(["a": "b"], merge: true)`.
+- [changed] Replaced the `SnapshotOptions` object with direct use of the
+ `FIRServerTimestampBehavior` on `DocumentSnapshot`. Instead of calling
+ `data(SnapshotOptions.serverTimestampBehavior(.estimate))` call
+ `data(serverTimestampBehavior: .estimate)`. Changed `get` similarly.
# v0.11.0
- [fixed] Fixed a regression in the Firebase iOS SDK release 4.11.0 that could
diff --git a/Firestore/Example/SwiftBuildTest/main.swift b/Firestore/Example/SwiftBuildTest/main.swift
index 8de5ed4..87b6cb4 100644
--- a/Firestore/Example/SwiftBuildTest/main.swift
+++ b/Firestore/Example/SwiftBuildTest/main.swift
@@ -198,13 +198,13 @@ func readDocument(at docRef: DocumentReference) {
if let data = document.data() {
print("Read document: \(data)")
}
- if let data = document.data(with: SnapshotOptions.serverTimestampBehavior(.estimate)) {
+ if let data = document.data(with: .estimate) {
print("Read document: \(data)")
}
if let foo = document.get("foo") {
print("Field: \(foo)")
}
- if let foo = document.get("foo", options: SnapshotOptions.serverTimestampBehavior(.previous)) {
+ if let foo = document.get("foo", serverTimestampBehavior: .previous) {
print("Field: \(foo)")
}
// Fields can also be read via subscript notation.
@@ -304,7 +304,7 @@ func listenToDocuments(matching query: Query) {
func listenToQueryDiffs(onQuery query: Query) {
let listener = query.addSnapshotListener { snap, error in
if let snap = snap {
- for change in snap.documentChanges {
+ for change in snap.documentChanges() {
switch change.type {
case .added:
print("New document: \(change.document.data())")
diff --git a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm
index 4d51434..e1ad3d2 100644
--- a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm
@@ -42,20 +42,11 @@
// Listener registration for a listener maintained during the course of the test.
id<FIRListenerRegistration> _listenerRegistration;
-
- // Snapshot options that return the previous value for pending server timestamps.
- FIRSnapshotOptions *_returnPreviousValue;
- FIRSnapshotOptions *_returnEstimatedValue;
}
- (void)setUp {
[super setUp];
- _returnPreviousValue =
- [FIRSnapshotOptions serverTimestampBehavior:FIRServerTimestampBehaviorPrevious];
- _returnEstimatedValue =
- [FIRSnapshotOptions serverTimestampBehavior:FIRServerTimestampBehaviorEstimate];
-
// Data written in tests via set.
_setData = @{
@"a" : @42,
@@ -124,10 +115,12 @@
/** Verifies a snapshot containing _setData but with a local estimate for the timestamps. */
- (void)verifyTimestampsAreEstimatedInSnapshot:(FIRDocumentSnapshot *)snapshot {
- id timestamp = [snapshot valueForField:@"when" options:_returnEstimatedValue];
+ id timestamp =
+ [snapshot valueForField:@"when" serverTimestampBehavior:FIRServerTimestampBehaviorEstimate];
XCTAssertTrue([timestamp isKindOfClass:[FIRTimestamp class]]);
- XCTAssertEqualObjects([snapshot dataWithOptions:_returnEstimatedValue],
- [self expectedDataWithTimestamp:timestamp]);
+ XCTAssertEqualObjects(
+ [snapshot dataWithServerTimestampBehavior:FIRServerTimestampBehaviorEstimate],
+ [self expectedDataWithTimestamp:timestamp]);
}
/**
@@ -137,11 +130,13 @@
- (void)verifyTimestampsInSnapshot:(FIRDocumentSnapshot *)snapshot
fromPreviousSnapshot:(nullable FIRDocumentSnapshot *)previousSnapshot {
if (previousSnapshot == nil) {
- XCTAssertEqualObjects([snapshot dataWithOptions:_returnPreviousValue],
- [self expectedDataWithTimestamp:[NSNull null]]);
+ XCTAssertEqualObjects(
+ [snapshot dataWithServerTimestampBehavior:FIRServerTimestampBehaviorPrevious],
+ [self expectedDataWithTimestamp:[NSNull null]]);
} else {
- XCTAssertEqualObjects([snapshot dataWithOptions:_returnPreviousValue],
- [self expectedDataWithTimestamp:previousSnapshot[@"when"]]);
+ XCTAssertEqualObjects(
+ [snapshot dataWithServerTimestampBehavior:FIRServerTimestampBehaviorPrevious],
+ [self expectedDataWithTimestamp:previousSnapshot[@"when"]]);
}
}
@@ -211,15 +206,20 @@
[_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}];
FIRDocumentSnapshot *localSnapshot = [self waitForLocalEvent];
XCTAssertEqualObjects([localSnapshot valueForField:@"a"], [NSNull null]);
- XCTAssertEqualObjects([localSnapshot valueForField:@"a" options:_returnPreviousValue], @42);
- XCTAssertTrue([[localSnapshot valueForField:@"a" options:_returnEstimatedValue]
- isKindOfClass:[FIRTimestamp class]]);
+ XCTAssertEqualObjects(
+ [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious],
+ @42);
+ XCTAssertTrue(
+ [[localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorEstimate]
+ isKindOfClass:[FIRTimestamp class]]);
FIRDocumentSnapshot *remoteSnapshot = [self waitForRemoteEvent];
XCTAssertTrue([[remoteSnapshot valueForField:@"a"] isKindOfClass:[FIRTimestamp class]]);
- XCTAssertTrue([[remoteSnapshot valueForField:@"a" options:_returnPreviousValue]
+ XCTAssertTrue([
+ [remoteSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious]
isKindOfClass:[FIRTimestamp class]]);
- XCTAssertTrue([[remoteSnapshot valueForField:@"a" options:_returnEstimatedValue]
+ XCTAssertTrue([
+ [remoteSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorEstimate]
isKindOfClass:[FIRTimestamp class]]);
}
@@ -232,11 +232,15 @@
[_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}];
FIRDocumentSnapshot *localSnapshot = [self waitForLocalEvent];
- XCTAssertEqualObjects([localSnapshot valueForField:@"a" options:_returnPreviousValue], @42);
+ XCTAssertEqualObjects(
+ [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious],
+ @42);
[_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}];
localSnapshot = [self waitForLocalEvent];
- XCTAssertEqualObjects([localSnapshot valueForField:@"a" options:_returnPreviousValue], @42);
+ XCTAssertEqualObjects(
+ [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious],
+ @42);
[self enableNetwork];
@@ -253,7 +257,9 @@
[_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}];
FIRDocumentSnapshot *localSnapshot = [self waitForLocalEvent];
- XCTAssertEqualObjects([localSnapshot valueForField:@"a" options:_returnPreviousValue], @42);
+ XCTAssertEqualObjects(
+ [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious],
+ @42);
[_docRef updateData:@{ @"a" : @1337 }];
localSnapshot = [self waitForLocalEvent];
@@ -261,7 +267,9 @@
[_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}];
localSnapshot = [self waitForLocalEvent];
- XCTAssertEqualObjects([localSnapshot valueForField:@"a" options:_returnPreviousValue], @1337);
+ XCTAssertEqualObjects(
+ [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious],
+ @1337);
[self enableNetwork];
diff --git a/Firestore/Source/API/FIRDocumentSnapshot.mm b/Firestore/Source/API/FIRDocumentSnapshot.mm
index 0fd59f4..614982b 100644
--- a/Firestore/Source/API/FIRDocumentSnapshot.mm
+++ b/Firestore/Source/API/FIRDocumentSnapshot.mm
@@ -24,7 +24,6 @@
#import "Firestore/Source/API/FIRFieldPath+Internal.h"
#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/API/FIRSnapshotMetadata+Internal.h"
-#import "Firestore/Source/API/FIRSnapshotOptions+Internal.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Source/Util/FSTAssert.h"
@@ -40,6 +39,21 @@ using firebase::firestore::model::DocumentKey;
NS_ASSUME_NONNULL_BEGIN
+/** Converts a public FIRServerTimestampBehavior into its internal equivalent. */
+static FSTServerTimestampBehavior InternalServerTimestampBehavor(
+ FIRServerTimestampBehavior behavior) {
+ switch (behavior) {
+ case FIRServerTimestampBehaviorNone:
+ return FSTServerTimestampBehaviorNone;
+ case FIRServerTimestampBehaviorEstimate:
+ return FSTServerTimestampBehaviorEstimate;
+ case FIRServerTimestampBehaviorPrevious:
+ return FSTServerTimestampBehaviorPrevious;
+ default:
+ FIREBASE_ASSERT_MESSAGE(false, "Unexpected server timestamp option: %ld", (long)behavior);
+ }
+}
+
@interface FIRDocumentSnapshot ()
- (instancetype)initWithFirestore:(FIRFirestore *)firestore
@@ -144,24 +158,23 @@ NS_ASSUME_NONNULL_BEGIN
}
- (nullable NSDictionary<NSString *, id> *)data {
- return [self dataWithOptions:[FIRSnapshotOptions defaultOptions]];
+ return [self dataWithServerTimestampBehavior:FIRServerTimestampBehaviorNone];
}
-- (nullable NSDictionary<NSString *, id> *)dataWithOptions:(FIRSnapshotOptions *)options {
+- (nullable NSDictionary<NSString *, id> *)dataWithServerTimestampBehavior:
+ (FIRServerTimestampBehavior)serverTimestampBehavior {
+ FSTFieldValueOptions *options = [self optionsForServerTimestampBehavior:serverTimestampBehavior];
return self.internalDocument == nil
? nil
- : [self convertedObject:[self.internalDocument data]
- options:[FSTFieldValueOptions
- optionsForSnapshotOptions:options
- timestampsInSnapshotsEnabled:
- self.firestore.settings.timestampsInSnapshotsEnabled]];
+ : [self convertedObject:[self.internalDocument data] options:options];
}
- (nullable id)valueForField:(id)field {
- return [self valueForField:field options:[FIRSnapshotOptions defaultOptions]];
+ return [self valueForField:field serverTimestampBehavior:FIRServerTimestampBehaviorNone];
}
-- (nullable id)valueForField:(id)field options:(FIRSnapshotOptions *)options {
+- (nullable id)valueForField:(id)field
+ serverTimestampBehavior:(FIRServerTimestampBehavior)serverTimestampBehavior {
FIRFieldPath *fieldPath;
if ([field isKindOfClass:[NSString class]]) {
@@ -173,13 +186,17 @@ NS_ASSUME_NONNULL_BEGIN
}
FSTFieldValue *fieldValue = [[self.internalDocument data] valueForPath:fieldPath.internalValue];
- return fieldValue == nil
- ? nil
- : [self convertedValue:fieldValue
- options:[FSTFieldValueOptions
- optionsForSnapshotOptions:options
- timestampsInSnapshotsEnabled:
- self.firestore.settings.timestampsInSnapshotsEnabled]];
+ FSTFieldValueOptions *options = [self optionsForServerTimestampBehavior:serverTimestampBehavior];
+ return fieldValue == nil ? nil : [self convertedValue:fieldValue options:options];
+}
+
+- (FSTFieldValueOptions *)optionsForServerTimestampBehavior:
+ (FIRServerTimestampBehavior)serverTimestampBehavior {
+ FSTServerTimestampBehavior internalBehavior =
+ InternalServerTimestampBehavor(serverTimestampBehavior);
+ return [[FSTFieldValueOptions alloc]
+ initWithServerTimestampBehavior:internalBehavior
+ timestampsInSnapshotsEnabled:self.firestore.settings.timestampsInSnapshotsEnabled];
}
- (nullable id)objectForKeyedSubscript:(id)key {
@@ -262,8 +279,10 @@ NS_ASSUME_NONNULL_BEGIN
return data;
}
-- (NSDictionary<NSString *, id> *)dataWithOptions:(FIRSnapshotOptions *)options {
- NSDictionary<NSString *, id> *data = [super dataWithOptions:options];
+- (NSDictionary<NSString *, id> *)dataWithServerTimestampBehavior:
+ (FIRServerTimestampBehavior)serverTimestampBehavior {
+ NSDictionary<NSString *, id> *data =
+ [super dataWithServerTimestampBehavior:serverTimestampBehavior];
FSTAssert(data, @"Document in a QueryDocumentSnapshot should exist");
return data;
}
diff --git a/Firestore/Source/API/FIRSnapshotOptions+Internal.h b/Firestore/Source/API/FIRSnapshotOptions+Internal.h
deleted file mode 100644
index 64e7dbc..0000000
--- a/Firestore/Source/API/FIRSnapshotOptions+Internal.h
+++ /dev/null
@@ -1,38 +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 "FIRDocumentSnapshot.h"
-
-#import <Foundation/Foundation.h>
-
-#import "Firestore/Source/Model/FSTFieldValue.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface FIRSnapshotOptions (Internal)
-
-/** Returns a default instance of FIRSnapshotOptions that specifies no options. */
-+ (instancetype)defaultOptions;
-
-/* Initializes a new instance with the specified server timestamp behavior. */
-- (instancetype)initWithServerTimestampBehavior:(FSTServerTimestampBehavior)serverTimestampBehavior;
-
-/* Returns the server timestamp behavior. Returns -1 if no behavior is specified. */
-- (FSTServerTimestampBehavior)serverTimestampBehavior;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/API/FIRSnapshotOptions.mm b/Firestore/Source/API/FIRSnapshotOptions.mm
deleted file mode 100644
index 72ea3cc..0000000
--- a/Firestore/Source/API/FIRSnapshotOptions.mm
+++ /dev/null
@@ -1,72 +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 "FIRDocumentSnapshot.h"
-
-#import "Firestore/Source/API/FIRSnapshotOptions+Internal.h"
-#import "Firestore/Source/Util/FSTAssert.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface FIRSnapshotOptions ()
-
-@property(nonatomic) FSTServerTimestampBehavior serverTimestampBehavior;
-
-@end
-
-@implementation FIRSnapshotOptions
-
-- (instancetype)initWithServerTimestampBehavior:
- (FSTServerTimestampBehavior)serverTimestampBehavior {
- self = [super init];
-
- if (self) {
- _serverTimestampBehavior = serverTimestampBehavior;
- }
-
- return self;
-}
-
-+ (instancetype)defaultOptions {
- static FIRSnapshotOptions *sharedInstance = nil;
- static dispatch_once_t onceToken;
-
- dispatch_once(&onceToken, ^{
- sharedInstance =
- [[FIRSnapshotOptions alloc] initWithServerTimestampBehavior:FSTServerTimestampBehaviorNone];
- });
-
- return sharedInstance;
-}
-
-+ (instancetype)serverTimestampBehavior:(FIRServerTimestampBehavior)serverTimestampBehavior {
- switch (serverTimestampBehavior) {
- case FIRServerTimestampBehaviorEstimate:
- return [[FIRSnapshotOptions alloc]
- initWithServerTimestampBehavior:FSTServerTimestampBehaviorEstimate];
- case FIRServerTimestampBehaviorPrevious:
- return [[FIRSnapshotOptions alloc]
- initWithServerTimestampBehavior:FSTServerTimestampBehaviorPrevious];
- case FIRServerTimestampBehaviorNone:
- return [FIRSnapshotOptions defaultOptions];
- default:
- FSTFail(@"Encountered unknown server timestamp behavior: %d", (int)serverTimestampBehavior);
- }
-}
-
-@end
-
-NS_ASSUME_NONNULL_END \ No newline at end of file
diff --git a/Firestore/Source/Model/FSTFieldValue.h b/Firestore/Source/Model/FSTFieldValue.h
index 6914f4d..6f9798a 100644
--- a/Firestore/Source/Model/FSTFieldValue.h
+++ b/Firestore/Source/Model/FSTFieldValue.h
@@ -25,7 +25,6 @@
@class FIRTimestamp;
@class FSTFieldValueOptions;
@class FIRGeoPoint;
-@class FIRSnapshotOptions;
NS_ASSUME_NONNULL_BEGIN
@@ -67,10 +66,6 @@ typedef NS_ENUM(NSInteger, FSTServerTimestampBehavior) {
timestampsInSnapshotsEnabled:(BOOL)timestampsInSnapshotsEnabled
NS_DESIGNATED_INITIALIZER;
-/** Creates an FSTFieldValueOptions instance from FIRSnapshotOptions. */
-+ (instancetype)optionsForSnapshotOptions:(FIRSnapshotOptions *)value
- timestampsInSnapshotsEnabled:(BOOL)timestampsInSnapshotsEnabled;
-
@end
/**
diff --git a/Firestore/Source/Model/FSTFieldValue.mm b/Firestore/Source/Model/FSTFieldValue.mm
index 0d7c649..9e77d39 100644
--- a/Firestore/Source/Model/FSTFieldValue.mm
+++ b/Firestore/Source/Model/FSTFieldValue.mm
@@ -16,10 +16,10 @@
#import "Firestore/Source/Model/FSTFieldValue.h"
+#import "FIRDocumentSnapshot.h"
#import "FIRTimestamp.h"
#import "Firestore/Source/API/FIRGeoPoint+Internal.h"
-#import "Firestore/Source/API/FIRSnapshotOptions+Internal.h"
#import "Firestore/Source/Model/FSTDocumentKey.h"
#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTClasses.h"
@@ -46,28 +46,6 @@ NS_ASSUME_NONNULL_BEGIN
@implementation FSTFieldValueOptions
-+ (instancetype)optionsForSnapshotOptions:(FIRSnapshotOptions *)options
- timestampsInSnapshotsEnabled:(BOOL)timestampsInSnapshotsEnabled {
- FSTServerTimestampBehavior convertedServerTimestampBehavior = FSTServerTimestampBehaviorNone;
- switch (options.serverTimestampBehavior) {
- case FIRServerTimestampBehaviorNone:
- convertedServerTimestampBehavior = FSTServerTimestampBehaviorNone;
- break;
- case FIRServerTimestampBehaviorEstimate:
- convertedServerTimestampBehavior = FSTServerTimestampBehaviorEstimate;
- break;
- case FIRServerTimestampBehaviorPrevious:
- convertedServerTimestampBehavior = FSTServerTimestampBehaviorPrevious;
- break;
- default:
- FSTFail(@"Unexpected server timestamp option: %ld", (long)options.serverTimestampBehavior);
- }
-
- return
- [[FSTFieldValueOptions alloc] initWithServerTimestampBehavior:convertedServerTimestampBehavior
- timestampsInSnapshotsEnabled:timestampsInSnapshotsEnabled];
-}
-
- (instancetype)initWithServerTimestampBehavior:(FSTServerTimestampBehavior)serverTimestampBehavior
timestampsInSnapshotsEnabled:(BOOL)timestampsInSnapshotsEnabled {
self = [super init];
diff --git a/Firestore/Source/Public/FIRDocumentSnapshot.h b/Firestore/Source/Public/FIRDocumentSnapshot.h
index 6e79a7f..669fe07 100644
--- a/Firestore/Source/Public/FIRDocumentSnapshot.h
+++ b/Firestore/Source/Public/FIRDocumentSnapshot.h
@@ -48,29 +48,6 @@ typedef NS_ENUM(NSInteger, FIRServerTimestampBehavior) {
} NS_SWIFT_NAME(ServerTimestampBehavior);
/**
- * Options that configure how data is retrieved from a `DocumentSnapshot`
- * (e.g. the desired behavior for server timestamps that have not yet been set
- * to their final value).
- */
-NS_SWIFT_NAME(SnapshotOptions)
-@interface FIRSnapshotOptions : NSObject
-
-/** */
-- (instancetype)init __attribute__((unavailable("FIRSnapshotOptions cannot be created directly.")));
-
-/**
- * If set, controls the return value for `FieldValue.serverTimestamp()`
- * fields that have not yet been set to their final value.
- *
- * If omitted, `NSNull` will be returned by default.
- *
- * @return The created `FIRSnapshotOptions` object.
- */
-+ (instancetype)serverTimestampBehavior:(FIRServerTimestampBehavior)serverTimestampBehavior;
-
-@end
-
-/**
* A `FIRDocumentSnapshot` contains data read from a document in your Firestore database. The data
* can be extracted with the `data` property or by using subscript syntax to access a specific
* field.
@@ -105,7 +82,7 @@ NS_SWIFT_NAME(DocumentSnapshot)
* `NSNull`. You can use `dataWithOptions()` to configure this behavior.
*
* @return An `NSDictionary` containing all fields in the document or `nil` if the document doesn't
- * exist.
+ * exist.
*/
- (nullable NSDictionary<NSString *, id> *)data;
@@ -113,12 +90,13 @@ NS_SWIFT_NAME(DocumentSnapshot)
* Retrieves all fields in the document as a `Dictionary`. Returns `nil` if the document doesn't
* exist.
*
- * @param options `SnapshotOptions` to configure how data is returned from the snapshot (e.g. the
- * desired behavior for server timestamps that have not yet been set to their final value).
+ * @param serverTimestampBehavior Configures how server timestamps that have not yet been set to
+ * their final value are returned from the snapshot.
* @return A `Dictionary` containing all fields in the document or `nil` if the document doesn't
- * exist.
+ * exist.
*/
-- (nullable NSDictionary<NSString *, id> *)dataWithOptions:(FIRSnapshotOptions *)options;
+- (nullable NSDictionary<NSString *, id> *)dataWithServerTimestampBehavior:
+ (FIRServerTimestampBehavior)serverTimestampBehavior;
/**
* Retrieves a specific field from the document. Returns `nil` if the document or the field doesn't
@@ -140,14 +118,14 @@ NS_SWIFT_NAME(DocumentSnapshot)
* can use `get(_:options:)` to configure this behavior.
*
* @param field The field to retrieve.
- * @param options `SnapshotOptions` to configure how data is returned from the snapshot (e.g. the
- * desired behavior for server timestamps that have not yet been set to their final value).
+ * @param serverTimestampBehavior Configures how server timestamps that have not yet been set to
+ * their final value are returned from the snapshot.
* @return The value contained in the field or `nil` if the document or field doesn't exist.
*/
// clang-format off
- (nullable id)valueForField:(id)field
- options:(FIRSnapshotOptions *)options
- NS_SWIFT_NAME(get(_:options:));
+ serverTimestampBehavior:(FIRServerTimestampBehavior)serverTimestampBehavior
+ NS_SWIFT_NAME(get(_:serverTimestampBehavior:));
// clang-format on
/**
@@ -190,11 +168,12 @@ NS_SWIFT_NAME(QueryDocumentSnapshot)
/**
* Retrieves all fields in the document as a `Dictionary`.
*
- * @param options `SnapshotOptions` to configure how data is returned from the snapshot (e.g. the
- * desired behavior for server timestamps that have not yet been set to their final value).
+ * @param serverTimestampBehavior Configures how server timestamps that have not yet been set to
+ * their final value are returned from the snapshot.
* @return A `Dictionary` containing all fields in the document.
*/
-- (NSDictionary<NSString *, id> *)dataWithOptions:(FIRSnapshotOptions *)options;
+- (NSDictionary<NSString *, id> *)dataWithServerTimestampBehavior:
+ (FIRServerTimestampBehavior)serverTimestampBehavior;
@end