MongoDB C++ Driver  mongocxx-3.0.0
insert_many_builder.hpp
1 // Copyright 2015 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 <bsoncxx/stdx/optional.hpp>
18 #include <mongocxx/bulk_write.hpp>
19 #include <mongocxx/options/insert.hpp>
20 #include <mongocxx/result/insert_many.hpp>
21 #include <mongocxx/stdx.hpp>
22 
23 #include <mongocxx/config/prelude.hpp>
24 
25 namespace mongocxx {
26 MONGOCXX_INLINE_NAMESPACE_BEGIN
27 
33 class MONGOCXX_API insert_many_builder {
34  public:
41  explicit insert_many_builder(const options::insert& options);
42 
51  void operator()(const bsoncxx::document::view& doc);
52 
59  stdx::optional<result::insert_many> insert(collection* col) const;
60 
61  private:
62  bulk_write _writes;
63  result::insert_many::id_map _inserted_ids;
64  std::size_t _index;
65 };
66 
67 MONGOCXX_INLINE_NAMESPACE_END
68 } // namespace mongocxx
69 
70 #include <mongocxx/config/postlude.hpp>
Definition: bulk_write.hpp:22
Class to build an insert_many bulk write operation.
Definition: insert_many_builder.hpp:33
A read-only, non-owning view of a BSON document.
Definition: view.hpp:33
Class representing the optional arguments to a MongoDB insert operation.
Definition: insert.hpp:31
Class representing a batch of write operations that can be sent to the server as a group...
Definition: bulk_write.hpp:41
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:74