RLMFindOneAndModifyOptions.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2020 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import <Realm/RLMConstants.h>
  19. RLM_HEADER_AUDIT_BEGIN(nullability, sendability)
  20. @protocol RLMBSON;
  21. @class RLMSortDescriptor;
  22. /// Options to use when executing a `findOneAndUpdate`, `findOneAndReplace`,
  23. /// or `findOneAndDelete` command on a `RLMMongoCollection`.
  24. @interface RLMFindOneAndModifyOptions : NSObject
  25. /// Limits the fields to return for all matching documents.
  26. @property (nonatomic, nullable) id<RLMBSON> projection NS_REFINED_FOR_SWIFT;
  27. /// The order in which to return matching documents.
  28. @property (nonatomic, nullable) id<RLMBSON> sort NS_REFINED_FOR_SWIFT
  29. __attribute__((deprecated("Use `sorting` instead, which correctly sort more than one sort attribute", "sorting")));
  30. /// The order in which to return matching documents.
  31. @property (nonatomic) NSArray<id<RLMBSON>> *sorting NS_REFINED_FOR_SWIFT;
  32. /// Whether or not to perform an upsert, default is false
  33. /// (only available for find_one_and_replace and find_one_and_update)
  34. @property (nonatomic) BOOL upsert;
  35. /// When true then the new document is returned,
  36. /// Otherwise the old document is returned (default)
  37. /// (only available for findOneAndReplace and findOneAndUpdate)
  38. @property (nonatomic) BOOL shouldReturnNewDocument;
  39. /// Options to use when executing a `findOneAndUpdate`, `findOneAndReplace`,
  40. /// or `findOneAndDelete` command on a `RLMMongoCollection`.
  41. /// @param projection Limits the fields to return for all matching documents.
  42. /// @param sort The order in which to return matching documents.
  43. /// @param upsert Whether or not to perform an upsert, default is false
  44. /// (only available for findOneAndReplace and findOneAndUpdate)
  45. /// @param shouldReturnNewDocument When true then the new document is returned,
  46. /// Otherwise the old document is returned (default),
  47. /// (only available for findOneAndReplace and findOneAndUpdate)
  48. - (instancetype)initWithProjection:(id<RLMBSON> _Nullable)projection
  49. sort:(id<RLMBSON> _Nullable)sort
  50. upsert:(BOOL)upsert
  51. shouldReturnNewDocument:(BOOL)shouldReturnNewDocument
  52. __attribute__((deprecated("Please use `initWithProjection:sorting:upsert:shouldReturnNewDocument:`")))
  53. NS_SWIFT_UNAVAILABLE("Please see FindOneAndModifyOptions");
  54. /// Options to use when executing a `findOneAndUpdate`, `findOneAndReplace`,
  55. /// or `findOneAndDelete` command on a `RLMMongoCollection`.
  56. /// @param projection Limits the fields to return for all matching documents.
  57. /// @param sorting The order in which to return matching documents.
  58. /// @param upsert Whether or not to perform an upsert, default is false
  59. /// (only available for findOneAndReplace and findOneAndUpdate)
  60. /// @param shouldReturnNewDocument When true then the new document is returned,
  61. /// Otherwise the old document is returned (default),
  62. /// (only available for findOneAndReplace and findOneAndUpdate)
  63. - (instancetype)initWithProjection:(id<RLMBSON> _Nullable)projection
  64. sorting:(NSArray<id<RLMBSON>> *)sorting
  65. upsert:(BOOL)upsert
  66. shouldReturnNewDocument:(BOOL)shouldReturnNewDocument;
  67. @end
  68. RLM_HEADER_AUDIT_END(nullability, sendability)