MongoDB C++ Driver  mongocxx-3.10.2
bulk_write.hpp
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 
15 #pragma once
16 
17 #include <cstdint>
18 #include <map>
19 #include <vector>
20 
21 #include <mongocxx/result/bulk_write-fwd.hpp>
22 
23 #include <bsoncxx/document/value.hpp>
24 #include <bsoncxx/document/view.hpp>
25 #include <bsoncxx/types.hpp>
26 
27 #include <mongocxx/config/prelude.hpp>
28 
29 namespace mongocxx {
30 namespace v_noabi {
31 namespace result {
32 
36 class bulk_write {
37  public:
38  using id_map = std::map<std::size_t, bsoncxx::v_noabi::document::element>;
39 
40  // This constructor is public for testing purposes only
41  explicit bulk_write(bsoncxx::v_noabi::document::value raw_response);
42 
48  std::int32_t inserted_count() const;
49 
55  std::int32_t matched_count() const;
56 
64  std::int32_t modified_count() const;
65 
71  std::int32_t deleted_count() const;
72 
78  std::int32_t upserted_count() const;
79 
86  id_map upserted_ids() const;
87 
88  private:
89  MONGOCXX_PRIVATE bsoncxx::v_noabi::document::view view() const;
90 
92 
93  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const bulk_write&, const bulk_write&);
94  friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const bulk_write&, const bulk_write&);
95 };
96 
97 } // namespace result
98 } // namespace v_noabi
99 } // namespace mongocxx
100 
101 #include <mongocxx/config/postlude.hpp>
A read-only BSON document that owns its underlying buffer.
Definition: value.hpp:38
A read-only, non-owning view of a BSON document.
Definition: view.hpp:35
Class representing the result of a MongoDB bulk write operation.
Definition: bulk_write.hpp:36
std::int32_t modified_count() const
Gets the number of documents that were modified during this operation.
std::int32_t upserted_count() const
Gets the number of documents that were upserted during this operation.
std::int32_t inserted_count() const
Gets the number of documents that were inserted during this operation.
std::int32_t matched_count() const
Gets the number of documents that were matched during this operation.
std::int32_t deleted_count() const
Gets the number of documents that were deleted during this operation.
id_map upserted_ids() const
Gets the ids of the upserted documents.
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19