aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Model/FSTMutation.h
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/Source/Model/FSTMutation.h')
-rw-r--r--Firestore/Source/Model/FSTMutation.h64
1 files changed, 12 insertions, 52 deletions
diff --git a/Firestore/Source/Model/FSTMutation.h b/Firestore/Source/Model/FSTMutation.h
index 38c35bf..7261f30 100644
--- a/Firestore/Source/Model/FSTMutation.h
+++ b/Firestore/Source/Model/FSTMutation.h
@@ -23,6 +23,7 @@
#include "Firestore/core/src/firebase/firestore/model/field_mask.h"
#include "Firestore/core/src/firebase/firestore/model/field_path.h"
#include "Firestore/core/src/firebase/firestore/model/field_transform.h"
+#include "Firestore/core/src/firebase/firestore/model/precondition.h"
#include "Firestore/core/src/firebase/firestore/model/transform_operations.h"
@class FSTDocument;
@@ -34,49 +35,6 @@
NS_ASSUME_NONNULL_BEGIN
-#pragma mark - FSTPrecondition
-
-typedef NS_ENUM(NSUInteger, FSTPreconditionExists) {
- FSTPreconditionExistsNotSet,
- FSTPreconditionExistsYes,
- FSTPreconditionExistsNo,
-};
-
-/**
- * Encodes a precondition for a mutation. This follows the model that the backend accepts with the
- * special case of an explicit "empty" precondition (meaning no precondition).
- */
-@interface FSTPrecondition : NSObject
-
-/** Creates a new FSTPrecondition with an exists flag. */
-+ (FSTPrecondition *)preconditionWithExists:(BOOL)exists;
-
-/** Creates a new FSTPrecondition based on a time the document exists at. */
-+ (FSTPrecondition *)preconditionWithUpdateTime:(FSTSnapshotVersion *)updateTime;
-
-/** Returns a precondition representing no precondition. */
-+ (FSTPrecondition *)none;
-
-/**
- * Returns true if the preconditions is valid for the given document (or null if no document is
- * available).
- */
-- (BOOL)isValidForDocument:(FSTMaybeDocument *_Nullable)maybeDoc;
-
-/** Returns whether this Precondition represents no precondition. */
-- (BOOL)isNone;
-
-/** If set, preconditions a mutation based on the last updateTime. */
-@property(nonatomic, strong, readonly, nullable) FSTSnapshotVersion *updateTime;
-
-/**
- * If set, preconditions a mutation based on whether the document exists.
- * Uses FSTPreconditionExistsNotSet to mark as unset.
- */
-@property(nonatomic, assign, readonly) FSTPreconditionExists exists;
-
-@end
-
#pragma mark - FSTMutationResult
@interface FSTMutationResult : NSObject
@@ -115,7 +73,8 @@ typedef NS_ENUM(NSUInteger, FSTPreconditionExists) {
- (id)init NS_UNAVAILABLE;
- (instancetype)initWithKey:(firebase::firestore::model::DocumentKey)key
- precondition:(FSTPrecondition *)precondition NS_DESIGNATED_INITIALIZER;
+ precondition:(firebase::firestore::model::Precondition)precondition
+ NS_DESIGNATED_INITIALIZER;
/**
* Applies this mutation to the given FSTDocument, FSTDeletedDocument or nil, if we don't have
@@ -176,8 +135,7 @@ typedef NS_ENUM(NSUInteger, FSTPreconditionExists) {
- (const firebase::firestore::model::DocumentKey &)key;
-/** The precondition for this mutation. */
-@property(nonatomic, strong, readonly) FSTPrecondition *precondition;
+- (const firebase::firestore::model::Precondition &)precondition;
@end
@@ -190,7 +148,7 @@ typedef NS_ENUM(NSUInteger, FSTPreconditionExists) {
@interface FSTSetMutation : FSTMutation
- (instancetype)initWithKey:(firebase::firestore::model::DocumentKey)key
- precondition:(FSTPrecondition *)precondition NS_UNAVAILABLE;
+ precondition:(firebase::firestore::model::Precondition)precondition NS_UNAVAILABLE;
/**
* Initializes the set mutation.
@@ -202,7 +160,8 @@ typedef NS_ENUM(NSUInteger, FSTPreconditionExists) {
*/
- (instancetype)initWithKey:(firebase::firestore::model::DocumentKey)key
value:(FSTObjectValue *)value
- precondition:(FSTPrecondition *)precondition NS_DESIGNATED_INITIALIZER;
+ precondition:(firebase::firestore::model::Precondition)precondition
+ NS_DESIGNATED_INITIALIZER;
/** The object value to use when setting the document. */
@property(nonatomic, strong, readonly) FSTObjectValue *value;
@@ -221,9 +180,9 @@ typedef NS_ENUM(NSUInteger, FSTPreconditionExists) {
*/
@interface FSTPatchMutation : FSTMutation
-/** Returns the precondition for the given FSTPrecondition. */
+/** Returns the precondition for the given Precondition. */
- (instancetype)initWithKey:(firebase::firestore::model::DocumentKey)key
- precondition:(FSTPrecondition *)precondition NS_UNAVAILABLE;
+ precondition:(firebase::firestore::model::Precondition)precondition NS_UNAVAILABLE;
/**
* Initializes a new patch mutation with an explicit FieldMask and FSTObjectValue representing
@@ -239,7 +198,8 @@ typedef NS_ENUM(NSUInteger, FSTPreconditionExists) {
- (instancetype)initWithKey:(firebase::firestore::model::DocumentKey)key
fieldMask:(firebase::firestore::model::FieldMask)fieldMask
value:(FSTObjectValue *)value
- precondition:(FSTPrecondition *)precondition NS_DESIGNATED_INITIALIZER;
+ precondition:(firebase::firestore::model::Precondition)precondition
+ NS_DESIGNATED_INITIALIZER;
/**
* A mask to apply to |value|, where only fields that are in both the fieldMask and the value
@@ -266,7 +226,7 @@ typedef NS_ENUM(NSUInteger, FSTPreconditionExists) {
@interface FSTTransformMutation : FSTMutation
- (instancetype)initWithKey:(firebase::firestore::model::DocumentKey)key
- precondition:(FSTPrecondition *)precondition NS_UNAVAILABLE;
+ precondition:(firebase::firestore::model::Precondition)precondition NS_UNAVAILABLE;
/**
* Initializes a new transform mutation with the specified field transforms.