MongoDB C++ Driver  mongocxx-3.10.2
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/bulk_write-fwd.hpp>
18 #include <mongocxx/collection-fwd.hpp>
19 
20 #include <mongocxx/client_session.hpp>
21 #include <mongocxx/model/write.hpp>
22 #include <mongocxx/options/bulk_write.hpp>
23 #include <mongocxx/result/bulk_write.hpp>
24 
25 #include <mongocxx/config/prelude.hpp>
26 
27 namespace mongocxx {
28 namespace v_noabi {
29 
44 class bulk_write {
45  public:
49  bulk_write(bulk_write&&) noexcept;
50 
54  bulk_write& operator=(bulk_write&&) noexcept;
55 
60 
83  bulk_write& append(const model::write& operation);
84 
94  stdx::optional<result::bulk_write> execute() const;
95 
96  private:
97  friend ::mongocxx::v_noabi::collection;
98 
99  class MONGOCXX_PRIVATE impl;
100 
101  MONGOCXX_PRIVATE bulk_write(const collection& coll,
102  const options::bulk_write& options,
103  const client_session* session = nullptr);
104 
105  bool _created_from_collection;
106  std::unique_ptr<impl> _impl;
107 };
108 
109 } // namespace v_noabi
110 } // namespace mongocxx
111 
112 #include <mongocxx/config/postlude.hpp>
Class representing a batch of write operations that can be sent to the server as a group.
Definition: bulk_write.hpp:44
stdx::optional< result::bulk_write > execute() const
Executes a bulk write.
bulk_write(bulk_write &&) noexcept
Move constructs a bulk write operation.
bulk_write & append(const model::write &operation)
Appends a single write to the bulk write operation.
Use a session for a sequence of operations, optionally with either causal consistency or snapshots.
Definition: client_session.hpp:47
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:86
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19