MongoDB C++ Driver mongocxx-4.0.0
Loading...
Searching...
No Matches
collection.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
17#include <algorithm>
18#include <string>
19
24
30#include <bsoncxx/oid.hpp>
33
37#include <mongocxx/cursor.hpp>
56#include <mongocxx/pipeline.hpp>
67
69
70namespace mongocxx {
71namespace v_noabi {
72
88 //
89 // Utility class supporting the convenience of {} meaning an empty bsoncxx::v_noabi::document.
90 //
91 // Users may not use this class directly.
92 //
93 // In places where driver methods take this class as a parameter, passing {} will
94 // translate to a default-constructed bsoncxx::v_noabi::document::view_or_value,
95 // regardless of other overloads taking other default-constructible types
96 // for that parameter. This class avoids compiler ambiguity with such overloads.
97 //
98 // See collection::update_one for an example of such overloads.
99 //
100 class _empty_doc_tag {};
101
102 public:
110
115
120
125
130
135
140 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const noexcept;
141
163 aggregate(const pipeline& pipeline, const options::aggregate& options = options::aggregate());
164
188 aggregate(const client_session& session,
189 const pipeline& pipeline,
190 const options::aggregate& options = options::aggregate());
191
203 create_bulk_write(const options::bulk_write& options = {});
204
218 create_bulk_write(const client_session& session, const options::bulk_write& options = {});
219
242 write(const model::write& write, const options::bulk_write& options = options::bulk_write()) {
243 return create_bulk_write(options).append(write).execute();
244 }
245
270 write(const client_session& session,
271 const model::write& write,
272 const options::bulk_write& options = options::bulk_write()) {
273 return create_bulk_write(session, options).append(write).execute();
274 }
275
298 template <typename container_type>
300 const container_type& writes, const options::bulk_write& options = options::bulk_write()) {
301 return bulk_write(writes.begin(), writes.end(), options);
302 }
303
328 template <typename container_type>
330 const client_session& session,
331 const container_type& writes,
332 const options::bulk_write& options = options::bulk_write()) {
333 return bulk_write(session, writes.begin(), writes.end(), options);
334 }
335
359 template <typename write_model_iterator_type>
361 write_model_iterator_type begin,
362 write_model_iterator_type end,
363 const options::bulk_write& options = options::bulk_write()) {
364 auto writes = create_bulk_write(options);
365 std::for_each(begin, end, [&](const model::write& current) { writes.append(current); });
366 return writes.execute();
367 }
368
394 template <typename write_model_iterator_type>
396 const client_session& session,
397 write_model_iterator_type begin,
398 write_model_iterator_type end,
399 const options::bulk_write& options = options::bulk_write()) {
400 auto writes = create_bulk_write(session, options);
401 std::for_each(begin, end, [&](const model::write& current) { writes.append(current); });
402 return writes.execute();
403 }
404
428 MONGOCXX_ABI_EXPORT_CDECL(std::int64_t)
429 count_documents(bsoncxx::v_noabi::document::view_or_value filter,
430 const options::count& options = options::count());
431
456 bsoncxx::v_noabi::document::view_or_value filter,
457 const options::count& options = options::count());
458
477 const options::estimated_document_count& options = options::estimated_document_count());
478
498 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::document::value)
499 create_index(bsoncxx::v_noabi::document::view_or_value keys,
500 bsoncxx::v_noabi::document::view_or_value index_options = {},
501 options::index_view operation_options = options::index_view{});
502
526 bsoncxx::v_noabi::document::view_or_value keys,
527 bsoncxx::v_noabi::document::view_or_value index_options = {},
528 options::index_view operation_options = options::index_view{});
529
548 delete_many(bsoncxx::v_noabi::document::view_or_value filter,
549 const options::delete_options& options = options::delete_options());
550
570 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::delete_result>)
572 bsoncxx::v_noabi::document::view_or_value filter,
573 const options::delete_options& options = options::delete_options());
574
592 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::delete_result>)
593 delete_one(bsoncxx::v_noabi::document::view_or_value filter,
594 const options::delete_options& options = options::delete_options());
595
615 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::delete_result>)
617 bsoncxx::v_noabi::document::view_or_value filter,
618 const options::delete_options& options = options::delete_options());
619
638 distinct(bsoncxx::v_noabi::string::view_or_value name,
639 bsoncxx::v_noabi::document::view_or_value filter,
640 const options::distinct& options = options::distinct());
641
662 distinct(const client_session& session,
663 bsoncxx::v_noabi::string::view_or_value name,
664 bsoncxx::v_noabi::document::view_or_value filter,
665 const options::distinct& options = options::distinct());
666
687 drop(const bsoncxx::v_noabi::stdx::optional<mongocxx::v_noabi::write_concern>& write_concern =
688 {},
689 bsoncxx::v_noabi::document::view_or_value collection_options = {});
690
712 drop(const client_session& session,
713 const bsoncxx::v_noabi::stdx::optional<mongocxx::v_noabi::write_concern>& write_concern =
714 {},
715 bsoncxx::v_noabi::document::view_or_value collection_options = {});
716
736 find(bsoncxx::v_noabi::document::view_or_value filter,
737 const options::find& options = options::find());
738
760 find(const client_session& session,
761 bsoncxx::v_noabi::document::view_or_value filter,
762 const options::find& options = options::find());
763
779 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
780 find_one(bsoncxx::v_noabi::document::view_or_value filter,
781 const options::find& options = options::find());
782
800 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
801 find_one(const client_session& session,
802 bsoncxx::v_noabi::document::view_or_value filter,
803 const options::find& options = options::find());
804
822 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
824 bsoncxx::v_noabi::document::view_or_value filter,
825 const options::find_one_and_delete& options = options::find_one_and_delete());
826
846 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
848 const client_session& session,
849 bsoncxx::v_noabi::document::view_or_value filter,
850 const options::find_one_and_delete& options = options::find_one_and_delete());
851
872 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
874 bsoncxx::v_noabi::document::view_or_value filter,
875 bsoncxx::v_noabi::document::view_or_value replacement,
876 const options::find_one_and_replace& options = options::find_one_and_replace());
877
900 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
902 const client_session& session,
903 bsoncxx::v_noabi::document::view_or_value filter,
904 bsoncxx::v_noabi::document::view_or_value replacement,
905 const options::find_one_and_replace& options = options::find_one_and_replace());
906
927 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
929 bsoncxx::v_noabi::document::view_or_value filter,
930 bsoncxx::v_noabi::document::view_or_value update,
931 const options::find_one_and_update& options = options::find_one_and_update());
932
953 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
955 bsoncxx::v_noabi::document::view_or_value filter,
956 const pipeline& update,
957 const options::find_one_and_update& options = options::find_one_and_update());
958
979 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
981 bsoncxx::v_noabi::document::view_or_value filter,
982 std::initializer_list<_empty_doc_tag> update,
983 const options::find_one_and_update& options = options::find_one_and_update());
984
1007 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
1009 const client_session& session,
1010 bsoncxx::v_noabi::document::view_or_value filter,
1011 bsoncxx::v_noabi::document::view_or_value update,
1012 const options::find_one_and_update& options = options::find_one_and_update());
1013
1036 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
1038 const client_session& session,
1039 bsoncxx::v_noabi::document::view_or_value filter,
1040 const pipeline& update,
1041 const options::find_one_and_update& options = options::find_one_and_update());
1042
1065 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
1067 const client_session& session,
1068 bsoncxx::v_noabi::document::view_or_value filter,
1069 std::initializer_list<_empty_doc_tag> update,
1070 const options::find_one_and_update& options = options::find_one_and_update());
1071
1087 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::insert_one>)
1088 insert_one(bsoncxx::v_noabi::document::view_or_value document,
1089 const options::insert& options = {});
1090
1111 bsoncxx::v_noabi::document::view_or_value document,
1112 const options::insert& options = {});
1113
1137 template <typename container_type>
1139 const container_type& container, const options::insert& options = options::insert()) {
1140 return insert_many(container.begin(), container.end(), options);
1141 }
1142
1164 template <typename container_type>
1166 const client_session& session,
1167 const container_type& container,
1168 const options::insert& options = options::insert()) {
1169 return insert_many(session, container.begin(), container.end(), options);
1170 }
1171
1195 template <typename document_view_iterator_type>
1197 document_view_iterator_type begin,
1198 document_view_iterator_type end,
1199 const options::insert& options = options::insert()) {
1200 return _insert_many(nullptr, begin, end, options);
1201 }
1202
1224 template <typename document_view_iterator_type>
1226 const client_session& session,
1227 document_view_iterator_type begin,
1228 document_view_iterator_type end,
1229 const options::insert& options = options::insert()) {
1230 return _insert_many(&session, begin, end, options);
1231 }
1232
1245
1260
1268
1289 rename(bsoncxx::v_noabi::string::view_or_value new_name,
1290 bool drop_target_before_rename = false,
1291 const bsoncxx::v_noabi::stdx::optional<write_concern>& write_concern = {});
1292
1315 rename(const client_session& session,
1316 bsoncxx::v_noabi::string::view_or_value new_name,
1317 bool drop_target_before_rename = false,
1318 const bsoncxx::v_noabi::stdx::optional<write_concern>& write_concern = {});
1319
1331
1341
1353
1363
1386 replace_one(bsoncxx::v_noabi::document::view_or_value filter,
1387 bsoncxx::v_noabi::document::view_or_value replacement,
1388 const options::replace& options = options::replace{});
1389
1415 bsoncxx::v_noabi::document::view_or_value filter,
1416 bsoncxx::v_noabi::document::view_or_value replacement,
1417 const options::replace& options = options::replace{});
1418
1441 update_many(bsoncxx::v_noabi::document::view_or_value filter,
1442 bsoncxx::v_noabi::document::view_or_value update,
1443 const options::update& options = options::update());
1444
1466 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1467 update_many(bsoncxx::v_noabi::document::view_or_value filter,
1468 const pipeline& update,
1469 const options::update& options = options::update());
1470
1492 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1493 update_many(bsoncxx::v_noabi::document::view_or_value filter,
1494 std::initializer_list<_empty_doc_tag> update,
1495 const options::update& options = options::update());
1496
1520 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1522 bsoncxx::v_noabi::document::view_or_value filter,
1523 bsoncxx::v_noabi::document::view_or_value update,
1524 const options::update& options = options::update());
1525
1549 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1551 bsoncxx::v_noabi::document::view_or_value filter,
1552 const pipeline& update,
1553 const options::update& options = options::update());
1554
1578 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1580 bsoncxx::v_noabi::document::view_or_value filter,
1581 std::initializer_list<_empty_doc_tag> update,
1582 const options::update& options = options::update());
1583
1605 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1606 update_one(bsoncxx::v_noabi::document::view_or_value filter,
1607 bsoncxx::v_noabi::document::view_or_value update,
1608 const options::update& options = options::update());
1609
1631 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1632 update_one(bsoncxx::v_noabi::document::view_or_value filter,
1633 const pipeline& update,
1634 const options::update& options = options::update());
1635
1657 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1658 update_one(bsoncxx::v_noabi::document::view_or_value filter,
1659 std::initializer_list<_empty_doc_tag> update,
1660 const options::update& options = options::update());
1661
1685 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1687 bsoncxx::v_noabi::document::view_or_value filter,
1688 bsoncxx::v_noabi::document::view_or_value update,
1689 const options::update& options = options::update());
1690
1714 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1716 bsoncxx::v_noabi::document::view_or_value filter,
1717 const pipeline& update,
1718 const options::update& options = options::update());
1719
1743 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1745 bsoncxx::v_noabi::document::view_or_value filter,
1746 std::initializer_list<_empty_doc_tag> update,
1747 const options::update& options = options::update());
1748
1757
1764
1769
1785
1799 watch(const client_session& session, const options::change_stream& options = {});
1800
1819 watch(const pipeline& pipe, const options::change_stream& options = {});
1820
1838 watch(const client_session& session,
1839 const pipeline& pipe,
1840 const options::change_stream& options = {});
1841
1846
1847 private:
1848 friend ::mongocxx::v_noabi::bulk_write;
1849 friend ::mongocxx::v_noabi::client_encryption;
1850 friend ::mongocxx::v_noabi::database;
1851
1853
1854 collection(const database& database, void* collection);
1855
1856 cursor _aggregate(const client_session* session,
1857 const pipeline& pipeline,
1858 const options::aggregate& options);
1859
1860 std::int64_t _count(const client_session* session,
1862 const options::count& options);
1863
1864 std::int64_t _count_documents(const client_session* session,
1866 const options::count& options);
1867
1869 const client_session* session,
1872 options::index_view operation_options);
1873
1875 const client_session* session,
1877 const options::delete_options& options);
1878
1880 const client_session* session,
1882 const options::delete_options& options);
1883
1884 cursor _distinct(const client_session* session,
1887 const options::distinct& options);
1888
1889 void _drop(
1890 const client_session* session,
1893
1894 cursor _find(const client_session* session,
1896 const options::find& options);
1897
1899 const client_session* session,
1901 const options::find& options);
1902
1904 const client_session* session,
1906 const options::find_one_and_delete& options);
1907
1909 const client_session* session,
1912 const options::find_one_and_replace& options);
1913
1915 const client_session* session,
1918 const options::find_one_and_update& options);
1919
1921 const client_session* session,
1923 const options::insert& options);
1924
1925 void _rename(
1926 const client_session* session,
1928 bool drop_target_before_rename,
1930
1932 const client_session* session,
1933 const options::bulk_write& bulk_opts,
1934 const model::replace_one& replace_op);
1935
1937 const client_session* session,
1940 const options::replace& options);
1941
1943 const client_session* session,
1946 const options::update& options);
1947
1949 const client_session* session,
1952 const options::update& options);
1953
1954 change_stream _watch(const client_session* session,
1955 const pipeline& pipe,
1956 const options::change_stream& options);
1957
1958 // Helpers for the insert_many method templates.
1960 _init_insert_many(const options::insert& options, const client_session* session);
1961
1963 _insert_many_doc_handler(mongocxx::v_noabi::bulk_write& writes,
1966
1968 _exec_insert_many(mongocxx::v_noabi::bulk_write& writes,
1970
1971 template <typename document_view_iterator_type>
1973 const client_session* session,
1974 document_view_iterator_type begin,
1975 document_view_iterator_type end,
1976 const options::insert& options) {
1978 auto writes = _init_insert_many(options, session);
1979 std::for_each(
1980 begin, end, [&inserted_ids, &writes, this](bsoncxx::v_noabi::document::view doc) {
1981 _insert_many_doc_handler(writes, inserted_ids, doc);
1982 });
1983 return _exec_insert_many(writes, inserted_ids);
1984 }
1985
1986 class impl;
1987
1988 impl& _get_impl();
1989 const impl& _get_impl() const;
1990
1991 std::unique_ptr<impl> _impl;
1992};
1993
1994} // namespace v_noabi
1995} // namespace mongocxx
1996
1998
Provides mongocxx::v_noabi::options::aggregate.
Provides bsoncxx::v_noabi::builder::basic::array.
Provides bsoncxx::v_noabi::builder::basic::document.
Declares mongocxx::v_noabi::bulk_write.
Provides mongocxx::v_noabi::bulk_write.
Provides mongocxx::v_noabi::change_stream.
A traditional builder-style interface for constructing a BSON array.
Definition array.hpp:37
A read-only BSON document that owns its underlying buffer. When a document::value goes out of scope,...
Definition value.hpp:38
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
A polyfill for std::optional<T>.
Definition optional.hpp:826
A polyfill for std::string_view.
Definition string_view.hpp:436
Class representing a view-or-value variant type for strings.
Definition view_or_value.hpp:41
mongocxx::v_noabi::cursor
Definition cursor-fwd.hpp:45
Class representing a batch of write operations that can be sent to the server as a group.
Definition bulk_write.hpp:45
bsoncxx::v_noabi::stdx::optional< result::bulk_write > execute() const
Executes a bulk write.
bulk_write & append(const model::write &operation)
Appends a single write to the bulk write operation. The write operation's contents are copied into th...
Class representing a MongoDB change stream.
Definition change_stream.hpp:35
Use a session for a sequence of operations, optionally with either causal consistency or snapshots.
Definition client_session.hpp:48
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:87
mongocxx::v_noabi::read_preference read_preference() const
Gets the read_preference for the collection.
std::int64_t count_documents(bsoncxx::v_noabi::document::view_or_value filter, const options::count &options=options::count())
Counts the number of documents matching the provided filter.
bsoncxx::v_noabi::stdx::optional< result::replace_one > replace_one(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement, const options::replace &options=options::replace{})
Replaces a single document matching the provided filter in this collection.
search_index_view search_indexes()
Gets a search_index_view to the collection.
bsoncxx::v_noabi::stdx::optional< result::update > update_many(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, const options::update &options=options::update())
Updates multiple documents matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one_and_replace(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement, const options::find_one_and_replace &options=options::find_one_and_replace())
Finds a single document matching the filter, replaces it, and returns either the original or the repl...
void read_concern(mongocxx::v_noabi::read_concern rc)
Sets the read_concern for this collection. Changes will not have any effect on existing cursors or ot...
bsoncxx::v_noabi::document::value create_index(bsoncxx::v_noabi::document::view_or_value keys, bsoncxx::v_noabi::document::view_or_value index_options={}, options::index_view operation_options=options::index_view{})
Creates an index over the collection for the provided keys with the provided options.
bsoncxx::v_noabi::stdx::optional< result::insert_many > insert_many(const client_session &session, const container_type &container, const options::insert &options=options::insert())
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1165
cursor aggregate(const pipeline &pipeline, const options::aggregate &options=options::aggregate())
Runs an aggregation framework pipeline against this collection.
bsoncxx::v_noabi::stdx::optional< result::bulk_write > bulk_write(const client_session &session, write_model_iterator_type begin, write_model_iterator_type end, const options::bulk_write &options=options::bulk_write())
Sends writes starting at begin and ending at end to the server as a bulk write operation.
Definition collection.hpp:395
bsoncxx::v_noabi::stdx::optional< result::insert_many > insert_many(document_view_iterator_type begin, document_view_iterator_type end, const options::insert &options=options::insert())
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1196
change_stream watch(const options::change_stream &options={})
Gets a change stream on this collection with an empty pipeline. Change streams are only supported wit...
void drop(const bsoncxx::v_noabi::stdx::optional< mongocxx::v_noabi::write_concern > &write_concern={}, bsoncxx::v_noabi::document::view_or_value collection_options={})
Drops this collection and all its contained documents from the database.
bsoncxx::v_noabi::stdx::optional< result::delete_result > delete_many(bsoncxx::v_noabi::document::view_or_value filter, const options::delete_options &options=options::delete_options())
Deletes all matching documents from the collection.
cursor list_indexes() const
Returns a list of the indexes currently on this collection.
bsoncxx::v_noabi::stdx::optional< result::bulk_write > bulk_write(const client_session &session, const container_type &writes, const options::bulk_write &options=options::bulk_write())
Sends a container of writes to the server as a bulk write operation.
Definition collection.hpp:329
cursor distinct(bsoncxx::v_noabi::string::view_or_value name, bsoncxx::v_noabi::document::view_or_value filter, const options::distinct &options=options::distinct())
Finds the distinct values for a specified field across the collection.
bsoncxx::v_noabi::stdx::optional< result::delete_result > delete_one(bsoncxx::v_noabi::document::view_or_value filter, const options::delete_options &options=options::delete_options())
Deletes a single matching document from the collection.
bsoncxx::v_noabi::stdx::string_view name() const
Returns the name of this collection.
mongocxx::v_noabi::read_concern read_concern() const
Gets the read_concern for the collection.
void read_preference(mongocxx::v_noabi::read_preference rp)
Sets the read_preference for this collection. Changes will not have any effect on existing cursors or...
bsoncxx::v_noabi::stdx::optional< result::bulk_write > bulk_write(const container_type &writes, const options::bulk_write &options=options::bulk_write())
Sends a container of writes to the server as a bulk write operation.
Definition collection.hpp:299
bsoncxx::v_noabi::stdx::optional< result::bulk_write > write(const model::write &write, const options::bulk_write &options=options::bulk_write())
Sends a write to the server as a bulk write operation.
Definition collection.hpp:242
bsoncxx::v_noabi::stdx::optional< result::bulk_write > bulk_write(write_model_iterator_type begin, write_model_iterator_type end, const options::bulk_write &options=options::bulk_write())
Sends writes starting at begin and ending at end to the server as a bulk write operation.
Definition collection.hpp:360
void rename(bsoncxx::v_noabi::string::view_or_value new_name, bool drop_target_before_rename=false, const bsoncxx::v_noabi::stdx::optional< write_concern > &write_concern={})
Rename this collection.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one_and_delete(bsoncxx::v_noabi::document::view_or_value filter, const options::find_one_and_delete &options=options::find_one_and_delete())
Finds a single document matching the filter, deletes it, and returns the original.
index_view indexes()
Gets an index_view to the collection.
mongocxx::v_noabi::bulk_write create_bulk_write(const options::bulk_write &options={})
Creates a new bulk operation to be executed against this collection. The lifetime of the bulk_write i...
bsoncxx::v_noabi::stdx::optional< result::insert_many > insert_many(const container_type &container, const options::insert &options=options::insert())
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1138
collection() noexcept
Default constructs a collection object. The collection is equivalent to the state of a moved from col...
cursor find(bsoncxx::v_noabi::document::view_or_value filter, const options::find &options=options::find())
Finds the documents in this collection which match the provided filter.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one_and_update(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, const options::find_one_and_update &options=options::find_one_and_update())
Finds a single document matching the filter, updates it, and returns either the original or the newly...
cursor list_indexes(const client_session &session) const
Returns a list of the indexes currently on this collection.
bsoncxx::v_noabi::stdx::optional< result::insert_one > insert_one(bsoncxx::v_noabi::document::view_or_value document, const options::insert &options={})
Inserts a single document into the collection. If the document is missing an identifier (_id field) o...
bsoncxx::v_noabi::stdx::optional< result::insert_many > insert_many(const client_session &session, document_view_iterator_type begin, document_view_iterator_type end, const options::insert &options=options::insert())
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1225
std::int64_t estimated_document_count(const options::estimated_document_count &options=options::estimated_document_count())
Returns an estimate of the number of documents in the collection.
bsoncxx::v_noabi::stdx::optional< result::update > update_one(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, const options::update &options=options::update())
Updates a single document matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one(bsoncxx::v_noabi::document::view_or_value filter, const options::find &options=options::find())
Finds a single document in this collection that match the provided filter.
Class representing a pointer to the result set of a query on a MongoDB server.
Definition cursor.hpp:42
Class representing a MongoDB database.
Definition database.hpp:46
Class representing a MongoDB index view.
Definition index_view.hpp:39
Class representing a MongoDB update operation that replaces a single document.
Definition replace_one.hpp:33
Models a single write operation within a mongocxx::v_noabi::bulk_write.
Definition write.hpp:40
Class representing the optional arguments to a MongoDB aggregation operation.
Definition aggregate.hpp:43
Class representing the optional arguments to a MongoDB bulk write.
Definition bulk_write.hpp:34
Class representing MongoDB change stream options.
Definition change_stream.hpp:38
Class representing the optional arguments to mongocxx::v_noabi::collection::count_documents.
Definition count.hpp:39
Class representing the optional arguments to a MongoDB delete operation.
Definition delete.hpp:35
Class representing the optional arguments to a MongoDB distinct command.
Definition distinct.hpp:38
Class representing the optional arguments to a MongoDB find_and_modify delete operation.
Definition find_one_and_delete.hpp:38
Class representing the optional arguments to a MongoDB find_and_modify replace operation.
Definition find_one_and_replace.hpp:39
Class representing the optional arguments to a MongoDB find_and_modify update operation.
Definition find_one_and_update.hpp:40
Class representing the optional arguments to a MongoDB query.
Definition find.hpp:40
Class representing optional arguments to IndexView operations.
Definition index_view.hpp:35
Class representing the optional arguments to a MongoDB insert operation.
Definition insert.hpp:34
Class representing the optional arguments to a MongoDB replace operation.
Definition replace.hpp:36
Class representing the optional arguments to a MongoDB update operation.
Definition update.hpp:36
Class representing a MongoDB aggregation pipeline.
Definition pipeline.hpp:39
A class to represent the read concern. Read concern can be set at the client, database,...
Definition read_concern.hpp:57
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition read_preference.hpp:64
Class representing a MongoDB search index view.
Definition search_index_view.hpp:24
Class representing the server-side requirement for reporting the success of a write operation....
Definition write_concern.hpp:60
Declares mongocxx::v_noabi::client_encryption.
Provides mongocxx::v_noabi::client_session.
Declares mongocxx::v_noabi::collection.
Provides concatenators for use with "streaming" BSON builder syntax.
Provides mongocxx::v_noabi::options::count.
Provides mongocxx::v_noabi::cursor.
Declares mongocxx::v_noabi::database.
Provides mongocxx::v_noabi::options::distinct.
Provides bsoncxx::v_noabi::document::view_or_value.
Provides mongocxx::v_noabi::options::estimated_document_count.
Provides mongocxx::v_noabi::options::find.
Provides mongocxx::v_noabi::options::find_one_and_delete.
Provides mongocxx::v_noabi::options::find_one_and_replace.
Provides mongocxx::v_noabi::options::find_one_and_update.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:204
Provides mongocxx::v_noabi::options::index.
Provides mongocxx::v_noabi::index_view.
Provides mongocxx::v_noabi::options::insert.
Provides mongocxx::v_noabi::result::insert_many.
Declares bsoncxx::v_noabi::builder::basic::kvp.
Provides mongocxx::v_noabi::model::insert_one.
The mongocxx macro guard postlude header.
The mongocxx macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace within which all mongocxx library entities are declared.
The top-level namespace reserved for the C++ standard library.
Provides bsoncxx::v_noabi::oid.
Provides std::optional-related polyfills for library API usage.
Provides mongocxx::v_noabi::options::bulk_write.
Provides mongocxx::v_noabi::options::change_stream.
Provides mongocxx::v_noabi::options::delete_options.
Provides mongocxx::v_noabi::options::index_view.
Provides mongocxx::v_noabi::options::update.
Provides mongocxx::v_noabi::pipeline.
Provides mongocxx::v_noabi::read_concern.
Provides mongocxx::v_noabi::read_preference.
Provides mongocxx::v_noabi::options::replace.
Provides mongocxx::v_noabi::result::bulk_write.
Provides mongocxx::v_noabi::result::delete_result.
Provides mongocxx::v_noabi::result::insert_one.
Provides mongocxx::v_noabi::result::replace_one.
Provides mongocxx::v_noabi::result::update.
Provides mongocxx::v_noabi::search_index_view.
Provides bsoncxx::v_noabi::string::view_or_value.
Provides mongocxx::v_noabi::write_concern.