replace_one.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <cstdint>
  16. #include <bsoncxx/stdx/optional.hpp>
  17. #include <bsoncxx/types.hpp>
  18. #include <mongocxx/result/bulk_write.hpp>
  19. #include <mongocxx/stdx.hpp>
  20. #include <mongocxx/config/prelude.hpp>
  21. namespace mongocxx {
  22. MONGOCXX_INLINE_NAMESPACE_BEGIN
  23. namespace result {
  24. /// Class representing the result of a MongoDB replace_one operation.
  25. class MONGOCXX_API replace_one {
  26. public:
  27. // This constructor is public for testing purposes only
  28. explicit replace_one(result::bulk_write result);
  29. ///
  30. /// Returns the bulk write result for this replace_one operation.
  31. ///
  32. /// @return The raw bulk write result.
  33. ///
  34. const result::bulk_write& result() const;
  35. ///
  36. /// Gets the number of documents that were matched during this operation.
  37. ///
  38. /// @return The number of documents that were matched.
  39. ///
  40. std::int32_t matched_count() const;
  41. ///
  42. /// Gets the number of documents that were modified during this operation.
  43. ///
  44. /// @return The number of documents that were modified.
  45. ///
  46. std::int32_t modified_count() const;
  47. ///
  48. /// Gets the id of the upserted document.
  49. ///
  50. /// @return The value of the _id field for upserted document.
  51. ///
  52. stdx::optional<bsoncxx::document::element> upserted_id() const;
  53. private:
  54. result::bulk_write _result;
  55. friend MONGOCXX_API bool MONGOCXX_CALL operator==(const replace_one&, const replace_one&);
  56. friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const replace_one&, const replace_one&);
  57. };
  58. } // namespace result
  59. MONGOCXX_INLINE_NAMESPACE_END
  60. } // namespace mongocxx
  61. #include <mongocxx/config/postlude.hpp>