MongoDB C++ Driver  mongocxx-3.7.0
bulk_write.hpp
1 // Copyright 2014-present 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 <mongocxx/client_session.hpp>
18 #include <mongocxx/model/write.hpp>
19 #include <mongocxx/options/bulk_write.hpp>
20 #include <mongocxx/result/bulk_write.hpp>
21 
22 #include <mongocxx/config/prelude.hpp>
23 
24 namespace mongocxx {
25 MONGOCXX_INLINE_NAMESPACE_BEGIN
26 
27 class collection;
28 
43 class MONGOCXX_API bulk_write {
44  public:
48  bulk_write(bulk_write&&) noexcept;
49 
53  bulk_write& operator=(bulk_write&&) noexcept;
54 
58  ~bulk_write();
59 
82  bulk_write& append(const model::write& operation);
83 
93  stdx::optional<result::bulk_write> execute() const;
94 
95  private:
96  friend class collection;
97 
98  class MONGOCXX_PRIVATE impl;
99 
100  MONGOCXX_PRIVATE bulk_write(const collection& coll,
101  const options::bulk_write& options,
102  const client_session* session = nullptr);
103 
104  bool _created_from_collection;
105  std::unique_ptr<impl> _impl;
106 };
107 
108 MONGOCXX_INLINE_NAMESPACE_END
109 } // namespace mongocxx
110 
111 #include <mongocxx/config/postlude.hpp>
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::model::write
Models a single write operation within a mongocxx::bulk_write.
Definition: write.hpp:37
mongocxx::client_session
Use a session for a sequence of operations, optionally with either causal consistency or snapshots.
Definition: client_session.hpp:40
mongocxx::bulk_write
Class representing a batch of write operations that can be sent to the server as a group.
Definition: bulk_write.hpp:43
mongocxx::collection
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:83
mongocxx::options::bulk_write
Class representing the optional arguments to a MongoDB bulk write.
Definition: bulk_write.hpp:31