delete_many.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Copyright 2014 MongoDB Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <bsoncxx/document/view_or_value.hpp>
  16. #include <bsoncxx/stdx/optional.hpp>
  17. #include <mongocxx/hint.hpp>
  18. #include <mongocxx/stdx.hpp>
  19. #include <mongocxx/config/prelude.hpp>
  20. namespace mongocxx {
  21. MONGOCXX_INLINE_NAMESPACE_BEGIN
  22. namespace model {
  23. ///
  24. /// Class representing a MongoDB delete operation that removes multiple documents.
  25. ///
  26. class MONGOCXX_API delete_many {
  27. public:
  28. ///
  29. /// Constructs a delete operation that will delete all documents matching the filter.
  30. ///
  31. /// @param filter
  32. /// Document representing the criteria for deletion.
  33. ///
  34. explicit delete_many(bsoncxx::document::view_or_value filter);
  35. ///
  36. /// Gets the filter for this delete operation.
  37. ///
  38. /// @return The filter to be used for the delete operation.
  39. ///
  40. const bsoncxx::document::view_or_value& filter() const;
  41. ///
  42. /// Sets the collation for this delete operation.
  43. ///
  44. /// @param collation
  45. /// The new collation.
  46. ///
  47. /// @return
  48. /// A reference to the object on which this member function is being called. This facilitates
  49. /// method chaining.
  50. ///
  51. /// @see
  52. /// https://docs.mongodb.com/master/reference/collation/
  53. ///
  54. delete_many& collation(bsoncxx::document::view_or_value collation);
  55. ///
  56. /// Gets the collation option for this delete operation.
  57. ///
  58. /// @return
  59. /// The optional value of the collation option.
  60. ///
  61. /// @see
  62. /// https://docs.mongodb.com/master/reference/collation/
  63. ///
  64. const stdx::optional<bsoncxx::document::view_or_value>& collation() const;
  65. /// Sets the index to use for this operation.
  66. ///
  67. /// @note if the server already has a cached shape for this query, it may
  68. /// ignore a hint.
  69. ///
  70. /// @param index_hint
  71. /// Object representing the index to use.
  72. ///
  73. /// @return
  74. /// A reference to the object on which this member function is being called. This facilitates
  75. /// method chaining.
  76. ///
  77. delete_many& hint(class hint index_hint);
  78. ///
  79. /// Gets the current hint.
  80. ///
  81. /// @return The current hint, if one is set.
  82. ///
  83. const stdx::optional<class hint>& hint() const;
  84. private:
  85. bsoncxx::document::view_or_value _filter;
  86. stdx::optional<bsoncxx::document::view_or_value> _collation;
  87. stdx::optional<class hint> _hint;
  88. };
  89. } // namespace model
  90. MONGOCXX_INLINE_NAMESPACE_END
  91. } // namespace mongocxx
  92. #include <mongocxx/config/postlude.hpp>