MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
bulk_write.hpp
Go to the documentation of this file.
1// Copyright 2009-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
18
19//
20
22
26
31
36
38
39#include <cstdint>
40#include <map>
41#include <utility>
42
43namespace mongocxx {
44namespace v1 {
45
54 private:
55 class impl;
56 void* _impl;
57
58 public:
93
94 class insert_one;
95 class update_one;
96 class update_many;
97 class replace_one;
98 class delete_one;
99 class delete_many;
100 class single;
101 class options;
102 class result;
103
108
116
123 MONGOCXX_ABI_EXPORT_CDECL(bulk_write&) operator=(bulk_write&& other) noexcept;
124
128 bulk_write(bulk_write const& other) = delete;
129
133 bulk_write& operator=(bulk_write const& other) = delete;
134
139
146
156
157 class internal;
158
159 private:
160 /* explicit(false) */ bulk_write(void* bulk);
161};
162
170 public:
175
179 /* explicit(false) */ insert_one(bsoncxx::v1::document::value doc) : value{std::move(doc)} {}
180
185 return value;
186 }
187};
188
205 private:
206 class impl;
207 void* _impl;
208
209 public:
216
224
231 MONGOCXX_ABI_EXPORT_CDECL(update_one&) operator=(update_one&& other) noexcept;
232
237
242
249 MONGOCXX_ABI_EXPORT_CDECL() update_one(bsoncxx::v1::document::value filter, bsoncxx::v1::document::value update);
250
258
262 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) filter() const;
263
267 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) update() const;
268
273
277 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) collation() const;
278
283
287 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::hint>) hint() const;
288
293
297 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) sort() const;
298
303
307 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bool>) upsert() const;
308
313
317 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::array::view>) array_filters() const;
318
319 class internal;
320};
321
335 private:
336 class impl;
337 void* _impl;
338
339 public:
346
354
361 MONGOCXX_ABI_EXPORT_CDECL(update_many&) operator=(update_many&& other) noexcept;
362
367
372
379 MONGOCXX_ABI_EXPORT_CDECL() update_many(bsoncxx::v1::document::value filter, bsoncxx::v1::document::value update);
380
385
389 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) filter() const;
390
394 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) update() const;
395
400
404 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) collation() const;
405
410
414 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::hint>) hint() const;
415
420
424 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bool>) upsert() const;
425
430
434 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::array::view>) array_filters() const;
435
436 class internal;
437
438 private:
439 /* explicit(false) */ update_many(void* impl);
440};
441
457 private:
458 class impl;
459 void* _impl;
460
461 public:
468
476
483 MONGOCXX_ABI_EXPORT_CDECL(replace_one&) operator=(replace_one&& other) noexcept;
484
489
494
502 bsoncxx::v1::document::value filter,
503 bsoncxx::v1::document::value replacement);
504
508 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) filter() const;
509
514
519
523 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) collation() const;
524
529
533 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::hint>) hint() const;
534
539
543 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) sort() const;
544
549
553 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bool>) upsert() const;
554
555 class internal;
556
557 private:
558 /* explicit(false) */ replace_one(void* impl);
559};
560
573 private:
574 class impl;
575 void* _impl;
576
577 public:
584
592
599 MONGOCXX_ABI_EXPORT_CDECL(delete_one&) operator=(delete_one&& other) noexcept;
600
605
610
617 explicit MONGOCXX_ABI_EXPORT_CDECL() delete_one(bsoncxx::v1::document::value filter);
618
622 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) filter() const;
623
628
632 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) collation() const;
633
638
642 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::hint>) hint() const;
643
644 class internal;
645
646 private:
647 /* explicit(false) */ delete_one(void* impl);
648};
649
662 private:
663 class impl;
664 void* _impl;
665
666 public:
673
681
688 MONGOCXX_ABI_EXPORT_CDECL(delete_many&) operator=(delete_many&& other) noexcept;
689
694
699
707
711 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) filter() const;
712
717
721 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) collation() const;
722
727
731 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::hint>) hint() const;
732
733 class internal;
734
735 private:
736 /* explicit(false) */ delete_many(void* impl);
737};
738
747 private:
748 class impl;
749 void* _impl;
750
751 public:
758
766
773 MONGOCXX_ABI_EXPORT_CDECL(single&) operator=(single&& other) noexcept;
774
779
783 MONGOCXX_ABI_EXPORT_CDECL(single&) operator=(single const& other);
784
789 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() single(insert_one op);
790 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() single(update_one op);
791 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() single(update_many op);
792 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() single(delete_one op);
793 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() single(delete_many op);
794 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() single(replace_one op);
797
802
814
826
838
850
862
874
875 class internal;
876};
877
894 private:
895 class impl;
896 void* _impl;
897
898 public:
905
913
920 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options&& other) noexcept;
921
926
930 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options const& other);
931
940
945
950
955
959 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::types::view>) comment() const;
960
965
969 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) let() const;
970
975
980
985
990
995
1000
1001 class internal;
1002
1003 private:
1004 /* explicit(false) */ options(void* impl);
1005};
1006
1024 private:
1025 class impl;
1026 void* _impl;
1027
1028 public:
1035
1043
1050 MONGOCXX_ABI_EXPORT_CDECL(result&) operator=(result&& other) noexcept;
1051
1056
1060 MONGOCXX_ABI_EXPORT_CDECL(result&) operator=(result const& other);
1061
1066
1071
1076
1081
1086
1090 using id_map = std::map<std::int64_t, bsoncxx::v1::types::view>;
1091
1098
1103 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(result const& lhs, result const& rhs);
1104
1105 friend bool operator!=(result const& lhs, result const& rhs) {
1106 return !(lhs == rhs);
1107 }
1108
1110
1111 class internal;
1112
1113 private:
1114 /* explicit(false) */ result(void* impl);
1115};
1116
1117} // namespace v1
1118} // namespace mongocxx
1119
1121
A BSON document.
Definition value.hpp:44
A single "Delete Many" write operation.
Definition bulk_write.hpp:661
bsoncxx::v1::document::view filter() const
Return the current "filter" field.
delete_many & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
~delete_many()
Destroy this object.
delete_many(delete_many &&other) noexcept
Move constructor.
delete_many & hint(v1::hint v)
Set the "hint" field.
A single "Delete One" write operation.
Definition bulk_write.hpp:572
bsoncxx::v1::document::view filter() const
Return the current "filter" field.
delete_one & hint(v1::hint v)
Set the "hint" field.
~delete_one()
Destroy this object.
delete_one & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
delete_one(delete_one &&other) noexcept
Move constructor.
A single "Insert One" write operation.
Definition bulk_write.hpp:169
insert_one(bsoncxx::v1::document::value doc)
Initialize with doc.
Definition bulk_write.hpp:179
bsoncxx::v1::document::value const & document() const
Equivalent to this->value.
Definition bulk_write.hpp:184
bsoncxx::v1::document::value value
The document to be inserted.
Definition bulk_write.hpp:174
options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
options & bypass_document_validation(bool v)
Set the "bypassDocumentValidation" field.
options & comment(bsoncxx::v1::types::value v)
Set the "comment" field.
options(options &&other) noexcept
Move constructor.
~options()
Destroy this object.
options & let(bsoncxx::v1::document::value v)
Set the "let" field.
options & read_concern(v1::read_concern v)
Set the "readConcern" field.
options & ordered(bool v)
Set the "ordered" field.
A single "Replace One" write operation.
Definition bulk_write.hpp:456
~replace_one()
Destroy this object.
bsoncxx::v1::document::view filter() const
Return the current "filter" field.
replace_one & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
replace_one & sort(bsoncxx::v1::document::value v)
Set the "sort" field.
replace_one(replace_one &&other) noexcept
Move constructor.
replace_one & upsert(bool v)
Set the "upsert" field.
bsoncxx::v1::document::view replacement() const
Return the current "replacement" field.
replace_one & hint(v1::hint v)
Set the "hint" field.
The result of a write operation.
Definition bulk_write.hpp:1023
std::int64_t matched_count() const
Return the value of the "matchedCount" field.
std::map< std::int64_t, bsoncxx::v1::types::view > id_map
A map from the operation index to the upserted document ID.
Definition bulk_write.hpp:1090
std::int64_t upserted_count() const
Return the value of the "upsertedCount" field.
result(result &&other) noexcept
Move constructor.
id_map upserted_ids() const
Return the "upsertedIds" field as a a map from the operation index to the upserted document ID.
std::int64_t modified_count() const
Return the value of the "modifiedCount" field.
std::int64_t deleted_count() const
Return the value of the "deletedCount" field.
std::int64_t inserted_count() const
Return the value of the "insertedCount" field.
~result()
Destroy this object.
A single write operation.
Definition bulk_write.hpp:746
single(single &&other) noexcept
Move constructor.
replace_one const & get_replace_one() const &
Return this write operation as an mongocxx::v1::bulk_write::replace_one.
update_one const & get_update_one() const &
Return this write operation as an mongocxx::v1::bulk_write::update_one.
v1::bulk_write::type type() const
Return the type of this write operation.
~single()
Destroy this object.
update_many const & get_update_many() const &
Return this write operation as an mongocxx::v1::bulk_write::update_many.
delete_one const & get_delete_one() const &
Return this write operation as an mongocxx::v1::bulk_write::delete_one.
delete_many const & get_delete_many() const &
Return this write operation as an mongocxx::v1::bulk_write::delete_many.
insert_one const & get_insert_one() const &
Return this write operation as an mongocxx::v1::bulk_write::insert_one.
A single "Update Many" write operation.
Definition bulk_write.hpp:334
bsoncxx::v1::document::view update() const
Return the current "update" field.
bsoncxx::v1::document::view filter() const
Return the current "filter" field.
update_many & upsert(bool v)
Set the "upsert" field.
update_many & array_filters(bsoncxx::v1::array::value v)
Set the "arrayFilters" field.
update_many & hint(v1::hint v)
Set the "hint" field.
~update_many()
Destroy this object.
update_many(update_many &&other) noexcept
Move constructor.
update_many & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
A single "Update One" write operation.
Definition bulk_write.hpp:204
update_one(update_one &&other) noexcept
Move constructor.
update_one & array_filters(bsoncxx::v1::array::value v)
Set the "arrayFilters" field.
update_one & upsert(bool v)
Set the "upsert" field.
update_one & sort(bsoncxx::v1::document::value v)
Set the "sort" field.
update_one & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
bsoncxx::v1::document::view update() const
Return the current "update" field.
~update_one()
Destroy this object.
update_one & hint(v1::hint v)
Set the "hint" field.
bsoncxx::v1::document::view filter() const
Return the current "filter" field.
type
Enumeration identifying the type of a write operation.
Definition bulk_write.hpp:62
@ k_delete_one
A "Delete One" operation.
Definition bulk_write.hpp:71
@ k_insert_one
An "Insert One" operation.
Definition bulk_write.hpp:66
@ k_update_many
An "Update Many" operation.
Definition bulk_write.hpp:86
@ k_update_one
An "Update One" operation.
Definition bulk_write.hpp:81
@ k_delete_many
A "Delete Many" operation.
Definition bulk_write.hpp:76
@ k_replace_one
A "Replace One" operation.
Definition bulk_write.hpp:91
bulk_write & append(single const &op)
Append a single write operation.
~bulk_write()
Destroy this object.
bsoncxx::v1::stdx::optional< result > execute()
Execute the appended operations.
bulk_write(bulk_write &&other) noexcept
Move constructor.
bool empty() const
Return true when there are no appended operations.
A MongoDB aggregation pipeline.
Definition pipeline.hpp:41
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities representing options to use with various commands.
Declares entities representing the result of various commands.
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all mongocxx library entities are declared.
Provides bsoncxx::v1::array::value.
Declares bsoncxx::v1::array::view.
Declares entities related to bulk write operations.
Provides bsoncxx::v1::document::value.
Declares bsoncxx::v1::document::view.
Declares mongocxx::v1::hint.
Declares mongocxx::v1::pipeline.
Declares mongocxx::v1::read_concern.
Provides std::optional-related polyfills for library API usage.
Declares bsoncxx::v1::types::value.
Provides non-owning, read-only entities representing a BSON type value.
Declares mongocxx::v1::write_concern.