distinct.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 <chrono>
  16. #include <cstdint>
  17. #include <string>
  18. #include <bsoncxx/document/view_or_value.hpp>
  19. #include <bsoncxx/stdx/optional.hpp>
  20. #include <mongocxx/read_preference.hpp>
  21. #include <mongocxx/config/prelude.hpp>
  22. namespace mongocxx {
  23. MONGOCXX_INLINE_NAMESPACE_BEGIN
  24. namespace options {
  25. ///
  26. /// Class representing the optional arguments to a MongoDB distinct command.
  27. ///
  28. class MONGOCXX_API distinct {
  29. public:
  30. ///
  31. /// Sets the collation for this operation.
  32. ///
  33. /// @param collation
  34. /// The new collation.
  35. ///
  36. /// @return
  37. /// A reference to the object on which this member function is being called. This facilitates
  38. /// method chaining.
  39. ///
  40. /// @see https://docs.mongodb.com/master/reference/command/distinct/
  41. ///
  42. distinct& collation(bsoncxx::document::view_or_value collation);
  43. ///
  44. /// Retrieves the current collation for this operation.
  45. ///
  46. /// @return
  47. /// The current collation.
  48. ///
  49. /// @see https://docs.mongodb.com/master/reference/command/distinct/
  50. ///
  51. const stdx::optional<bsoncxx::document::view_or_value>& collation() const;
  52. ///
  53. /// Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
  54. ///
  55. /// @param max_time
  56. /// The max amount of time (in milliseconds).
  57. ///
  58. /// @return
  59. /// A reference to the object on which this member function is being called. This facilitates
  60. /// method chaining.
  61. ///
  62. /// @see https://docs.mongodb.com/master/reference/command/distinct/
  63. ///
  64. distinct& max_time(std::chrono::milliseconds max_time);
  65. ///
  66. /// The current max_time setting.
  67. ///
  68. /// @return The current max time (in milliseconds).
  69. ///
  70. /// @see https://docs.mongodb.com/master/reference/command/distinct/
  71. ///
  72. const stdx::optional<std::chrono::milliseconds>& max_time() const;
  73. ///
  74. /// Sets the read_preference for this operation.
  75. ///
  76. /// @param rp
  77. /// The new read_preference.
  78. ///
  79. /// @return
  80. /// A reference to the object on which this member function is being called. This facilitates
  81. /// method chaining.
  82. ///
  83. /// @see https://docs.mongodb.com/master/reference/command/distinct/
  84. ///
  85. distinct& read_preference(class read_preference rp);
  86. ///
  87. /// The current read_preference for this operation.
  88. ///
  89. /// @return the current read_preference.
  90. ///
  91. /// @see https://docs.mongodb.com/master/reference/command/distinct/
  92. ///
  93. const stdx::optional<class read_preference>& read_preference() const;
  94. private:
  95. stdx::optional<bsoncxx::document::view_or_value> _collation;
  96. stdx::optional<std::chrono::milliseconds> _max_time;
  97. stdx::optional<class read_preference> _read_preference;
  98. };
  99. } // namespace options
  100. MONGOCXX_INLINE_NAMESPACE_END
  101. } // namespace mongocxx
  102. #include <mongocxx/config/postlude.hpp>