MongoDB C++ Driver mongocxx-3.0.0
Loading...
Searching...
No Matches
insert_many.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
20#include <bsoncxx/types.hpp>
21#include <mongocxx/result/bulk_write.hpp>
22
23#include <mongocxx/config/prelude.hpp>
24
25namespace mongocxx {
26MONGOCXX_INLINE_NAMESPACE_BEGIN
27
28class collection;
29class insert_many_builder;
30
31namespace result {
32
37class MONGOCXX_API insert_many {
38 public:
39 using id_map = std::map<std::size_t, bsoncxx::document::element>;
40
46 const result::bulk_write& result() const;
47
53 std::int32_t inserted_count() const;
54
60 id_map inserted_ids();
61
62 private:
63 friend collection;
65
66 MONGOCXX_PRIVATE insert_many(result::bulk_write result, id_map inserted_ids);
67
68 result::bulk_write _result;
69 id_map _generated_ids;
70};
71
72} // namespace result
73MONGOCXX_INLINE_NAMESPACE_END
74} // namespace mongocxx
75
76#include <mongocxx/config/postlude.hpp>
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:74
Class to build an insert_many bulk write operation.
Definition insert_many_builder.hpp:33
Class representing the result of a MongoDB bulk write operation.
Definition bulk_write.hpp:34
Class representing the result of a MongoDB insert many operation (executed as a bulk write).
Definition insert_many.hpp:37
id_map inserted_ids()
Gets the _ids of the inserted documents.
std::int32_t inserted_count() const
Gets the number of documents that were inserted during this operation.
const result::bulk_write & result() const
Returns the bulk write result for this insert many operation.