FSTTransaction.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "Firestore/Source/Core/FSTTypes.h"
  18. @class FIRSetOptions;
  19. @class FSTDatastore;
  20. @class FSTDocumentKey;
  21. @class FSTFieldMask;
  22. @class FSTFieldTransform;
  23. @class FSTMaybeDocument;
  24. @class FSTObjectValue;
  25. @class FSTParsedSetData;
  26. @class FSTParsedUpdateData;
  27. NS_ASSUME_NONNULL_BEGIN
  28. #pragma mark - FSTTransaction
  29. /** Provides APIs to use in a transaction context. */
  30. @interface FSTTransaction : NSObject
  31. /** Creates a new transaction object, which can only be used for one transaction attempt. **/
  32. + (instancetype)transactionWithDatastore:(FSTDatastore *)datastore;
  33. /**
  34. * Takes a set of keys and asynchronously attempts to fetch all the documents from the backend,
  35. * ignoring any local changes.
  36. */
  37. - (void)lookupDocumentsForKeys:(NSArray<FSTDocumentKey *> *)keys
  38. completion:(FSTVoidMaybeDocumentArrayErrorBlock)completion;
  39. /**
  40. * Stores mutation for the given key and set data, to be committed when commitWithCompletion is
  41. * called.
  42. */
  43. - (void)setData:(FSTParsedSetData *)data forDocument:(FSTDocumentKey *)key;
  44. /**
  45. * Stores mutations for the given key and update data, to be committed when commitWithCompletion
  46. * is called.
  47. */
  48. - (void)updateData:(FSTParsedUpdateData *)data forDocument:(FSTDocumentKey *)key;
  49. /**
  50. * Stores a delete mutation for the given key, to be committed when commitWithCompletion is called.
  51. */
  52. - (void)deleteDocument:(FSTDocumentKey *)key;
  53. /**
  54. * Attempts to commit the mutations set on this transaction. Calls the given completion block when
  55. * finished. Once this is called, no other mutations or commits are allowed on the transaction.
  56. */
  57. - (void)commitWithCompletion:(FSTVoidErrorBlock)completion;
  58. @end
  59. NS_ASSUME_NONNULL_END