MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
164
189 client_session const& session,
190 pipeline const& pipeline,
192
205
220
246
272 client_session const& session,
273 model::write const& write,
275 return create_bulk_write(session, options).append(write).execute();
276 }
277
300 template <typename container_type>
302 container_type const& writes,
304 return bulk_write(writes.begin(), writes.end(), options);
305 }
306
331 template <typename container_type>
333 client_session const& session,
334 container_type const& writes,
336 return bulk_write(session, writes.begin(), writes.end(), options);
337 }
338
362 template <typename write_model_iterator_type>
364 write_model_iterator_type begin,
365 write_model_iterator_type end,
367 auto writes = create_bulk_write(options);
368 std::for_each(begin, end, [&](model::write const& current) { writes.append(current); });
369 return writes.execute();
370 }
371
397 template <typename write_model_iterator_type>
399 client_session const& session,
400 write_model_iterator_type begin,
401 write_model_iterator_type end,
403 auto writes = create_bulk_write(session, options);
404 std::for_each(begin, end, [&](model::write const& current) { writes.append(current); });
405 return writes.execute();
406 }
407
431 MONGOCXX_ABI_EXPORT_CDECL(std::int64_t)
432 count_documents(bsoncxx::v_noabi::document::view_or_value filter, options::count const& options = options::count());
433
456 MONGOCXX_ABI_EXPORT_CDECL(std::int64_t)
458 client_session const& session,
459 bsoncxx::v_noabi::document::view_or_value filter,
460 options::count const& options = options::count());
461
478 MONGOCXX_ABI_EXPORT_CDECL(std::int64_t)
480
500 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::document::value)
502 bsoncxx::v_noabi::document::view_or_value keys,
503 bsoncxx::v_noabi::document::view_or_value index_options = {},
504 options::index_view operation_options = options::index_view{});
505
529 client_session const& session,
530 bsoncxx::v_noabi::document::view_or_value keys,
531 bsoncxx::v_noabi::document::view_or_value index_options = {},
532 options::index_view operation_options = options::index_view{});
533
553 bsoncxx::v_noabi::document::view_or_value filter,
554 options::delete_options const& options = options::delete_options());
555
575 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::delete_result>)
577 client_session const& session,
578 bsoncxx::v_noabi::document::view_or_value filter,
579 options::delete_options const& options = options::delete_options());
580
598 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::delete_result>)
600 bsoncxx::v_noabi::document::view_or_value filter,
601 options::delete_options const& options = options::delete_options());
602
622 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::delete_result>)
624 client_session const& session,
625 bsoncxx::v_noabi::document::view_or_value filter,
626 options::delete_options const& options = options::delete_options());
627
647 bsoncxx::v_noabi::string::view_or_value name,
648 bsoncxx::v_noabi::document::view_or_value filter,
650
672 client_session const& session,
673 bsoncxx::v_noabi::string::view_or_value name,
674 bsoncxx::v_noabi::document::view_or_value filter,
676
698 bsoncxx::v_noabi::stdx::optional<mongocxx::v_noabi::write_concern> const& write_concern = {},
699 bsoncxx::v_noabi::document::view_or_value collection_options = {});
700
723 client_session const& session,
724 bsoncxx::v_noabi::stdx::optional<mongocxx::v_noabi::write_concern> const& write_concern = {},
725 bsoncxx::v_noabi::document::view_or_value collection_options = {});
726
746 find(bsoncxx::v_noabi::document::view_or_value filter, options::find const& options = options::find());
747
770 client_session const& session,
771 bsoncxx::v_noabi::document::view_or_value filter,
772 options::find const& options = options::find());
773
789 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
790 find_one(bsoncxx::v_noabi::document::view_or_value filter, options::find const& options = options::find());
791
809 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
811 client_session const& session,
812 bsoncxx::v_noabi::document::view_or_value filter,
813 options::find const& options = options::find());
814
832 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
834 bsoncxx::v_noabi::document::view_or_value filter,
836
856 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
858 client_session const& session,
859 bsoncxx::v_noabi::document::view_or_value filter,
861
882 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
884 bsoncxx::v_noabi::document::view_or_value filter,
885 bsoncxx::v_noabi::document::view_or_value replacement,
887
910 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
912 client_session const& session,
913 bsoncxx::v_noabi::document::view_or_value filter,
914 bsoncxx::v_noabi::document::view_or_value replacement,
916
937 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
939 bsoncxx::v_noabi::document::view_or_value filter,
940 bsoncxx::v_noabi::document::view_or_value update,
942
963 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
965 bsoncxx::v_noabi::document::view_or_value filter,
966 pipeline const& update,
968
989 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
991 bsoncxx::v_noabi::document::view_or_value filter,
992 std::initializer_list<_empty_doc_tag> update,
994
1017 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
1019 client_session const& session,
1020 bsoncxx::v_noabi::document::view_or_value filter,
1021 bsoncxx::v_noabi::document::view_or_value update,
1023
1046 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
1048 client_session const& session,
1049 bsoncxx::v_noabi::document::view_or_value filter,
1050 pipeline const& update,
1052
1075 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
1077 client_session const& session,
1078 bsoncxx::v_noabi::document::view_or_value filter,
1079 std::initializer_list<_empty_doc_tag> update,
1081
1098 insert_one(bsoncxx::v_noabi::document::view_or_value document, options::insert const& options = {});
1099
1120 client_session const& session,
1121 bsoncxx::v_noabi::document::view_or_value document,
1122 options::insert const& options = {});
1123
1147 template <typename container_type>
1149 container_type const& container,
1151 return insert_many(container.begin(), container.end(), options);
1152 }
1153
1175 template <typename container_type>
1177 client_session const& session,
1178 container_type const& container,
1180 return insert_many(session, container.begin(), container.end(), options);
1181 }
1182
1206 template <typename document_view_iterator_type>
1208 document_view_iterator_type begin,
1209 document_view_iterator_type end,
1211 return _insert_many(nullptr, begin, end, options);
1212 }
1213
1235 template <typename document_view_iterator_type>
1237 client_session const& session,
1238 document_view_iterator_type begin,
1239 document_view_iterator_type end,
1241 return _insert_many(&session, begin, end, options);
1242 }
1243
1256
1271
1279
1301 bsoncxx::v_noabi::string::view_or_value new_name,
1302 bool drop_target_before_rename = false,
1303 bsoncxx::v_noabi::stdx::optional<write_concern> const& write_concern = {});
1304
1328 client_session const& session,
1329 bsoncxx::v_noabi::string::view_or_value new_name,
1330 bool drop_target_before_rename = false,
1331 bsoncxx::v_noabi::stdx::optional<write_concern> const& write_concern = {});
1332
1344
1354
1366
1376
1400 bsoncxx::v_noabi::document::view_or_value filter,
1401 bsoncxx::v_noabi::document::view_or_value replacement,
1402 options::replace const& options = options::replace{});
1403
1429 client_session const& session,
1430 bsoncxx::v_noabi::document::view_or_value filter,
1431 bsoncxx::v_noabi::document::view_or_value replacement,
1432 options::replace const& options = options::replace{});
1433
1457 bsoncxx::v_noabi::document::view_or_value filter,
1458 bsoncxx::v_noabi::document::view_or_value update,
1459 options::update const& options = options::update());
1460
1482 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1484 bsoncxx::v_noabi::document::view_or_value filter,
1485 pipeline const& update,
1486 options::update const& options = options::update());
1487
1509 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1511 bsoncxx::v_noabi::document::view_or_value filter,
1512 std::initializer_list<_empty_doc_tag> update,
1513 options::update const& options = options::update());
1514
1538 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1540 client_session const& session,
1541 bsoncxx::v_noabi::document::view_or_value filter,
1542 bsoncxx::v_noabi::document::view_or_value update,
1543 options::update const& options = options::update());
1544
1568 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1570 client_session const& session,
1571 bsoncxx::v_noabi::document::view_or_value filter,
1572 pipeline const& update,
1573 options::update const& options = options::update());
1574
1598 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1600 client_session const& session,
1601 bsoncxx::v_noabi::document::view_or_value filter,
1602 std::initializer_list<_empty_doc_tag> update,
1603 options::update const& options = options::update());
1604
1626 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1628 bsoncxx::v_noabi::document::view_or_value filter,
1629 bsoncxx::v_noabi::document::view_or_value update,
1630 options::update const& options = options::update());
1631
1653 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1655 bsoncxx::v_noabi::document::view_or_value filter,
1656 pipeline const& update,
1657 options::update const& options = options::update());
1658
1680 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1682 bsoncxx::v_noabi::document::view_or_value filter,
1683 std::initializer_list<_empty_doc_tag> update,
1684 options::update const& options = options::update());
1685
1709 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1711 client_session const& session,
1712 bsoncxx::v_noabi::document::view_or_value filter,
1713 bsoncxx::v_noabi::document::view_or_value update,
1714 options::update const& options = options::update());
1715
1739 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1741 client_session const& session,
1742 bsoncxx::v_noabi::document::view_or_value filter,
1743 pipeline const& update,
1744 options::update const& options = options::update());
1745
1769 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<result::update>)
1771 client_session const& session,
1772 bsoncxx::v_noabi::document::view_or_value filter,
1773 std::initializer_list<_empty_doc_tag> update,
1774 options::update const& options = options::update());
1775
1784
1791
1796
1812
1826 watch(client_session const& session, options::change_stream const& options = {});
1827
1846 watch(pipeline const& pipe, options::change_stream const& options = {});
1847
1865 watch(client_session const& session, pipeline const& pipe, options::change_stream const& options = {});
1866
1871
1872 private:
1873 friend ::mongocxx::v_noabi::bulk_write;
1874 friend ::mongocxx::v_noabi::client_encryption;
1875 friend ::mongocxx::v_noabi::database;
1876
1878
1879 collection(database const& database, void* collection);
1880
1881 cursor _aggregate(client_session const* session, pipeline const& pipeline, options::aggregate const& options);
1882
1883 std::int64_t _count(
1884 client_session const* session,
1886 options::count const& options);
1887
1888 std::int64_t _count_documents(
1889 client_session const* session,
1891 options::count const& options);
1892
1894 client_session const* session,
1897 options::index_view operation_options);
1898
1900 client_session const* session,
1903
1905 client_session const* session,
1908
1909 cursor _distinct(
1910 client_session const* session,
1913 options::distinct const& options);
1914
1915 void _drop(
1916 client_session const* session,
1919
1920 cursor _find(
1921 client_session const* session,
1923 options::find const& options);
1924
1926 client_session const* session,
1928 options::find const& options);
1929
1931 client_session const* session,
1934
1936 client_session const* session,
1940
1942 client_session const* session,
1946
1948 client_session const* session,
1950 options::insert const& options);
1951
1952 void _rename(
1953 client_session const* session,
1955 bool drop_target_before_rename,
1957
1959 client_session const* session,
1960 options::bulk_write const& bulk_opts,
1961 model::replace_one const& replace_op);
1962
1964 client_session const* session,
1967 options::replace const& options);
1968
1970 client_session const* session,
1973 options::update const& options);
1974
1976 client_session const* session,
1979 options::update const& options);
1980
1981 change_stream _watch(client_session const* session, pipeline const& pipe, options::change_stream const& options);
1982
1983 // Helpers for the insert_many method templates.
1985 _init_insert_many(options::insert const& options, client_session const* session);
1986
1988 _insert_many_doc_handler(
1992
1994 _exec_insert_many(mongocxx::v_noabi::bulk_write& writes, bsoncxx::v_noabi::builder::basic::array& inserted_ids);
1995
1996 template <typename document_view_iterator_type>
1998 client_session const* session,
1999 document_view_iterator_type begin,
2000 document_view_iterator_type end,
2001 options::insert const& options) {
2003 auto writes = _init_insert_many(options, session);
2004 std::for_each(begin, end, [&inserted_ids, &writes, this](bsoncxx::v_noabi::document::view doc) {
2005 _insert_many_doc_handler(writes, inserted_ids, doc);
2006 });
2007 return _exec_insert_many(writes, inserted_ids);
2008 }
2009
2010 class impl;
2011
2012 impl& _get_impl();
2013 impl const& _get_impl() const;
2014
2015 std::unique_ptr<impl> _impl;
2016};
2017
2018} // namespace v_noabi
2019} // namespace mongocxx
2020
2022
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 polyfill for std::optional<T>.
Definition optional.hpp:800
A polyfill for std::string_view.
Definition string_view.hpp:411
A traditional builder-style interface for constructing a BSON array.
Definition array.hpp:37
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:39
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
A view-or-value variant type for strings.
Definition view_or_value.hpp:41
collection() noexcept
Default constructs a collection object. The collection is equivalent to the state of a moved from col...
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(model::write const &operation)
Appends a single write to the bulk write operation. The write operation's contents are copied into th...
A MongoDB change stream.
Definition change_stream.hpp:35
Supports MongoDB client session operations.
Definition client_session.hpp:50
mongocxx::v_noabi::read_preference read_preference() const
Gets the read_preference for the collection.
void drop(bsoncxx::v_noabi::stdx::optional< mongocxx::v_noabi::write_concern > const &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::insert_many > insert_many(container_type const &container, options::insert const &options=options::insert())
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1148
bsoncxx::v_noabi::stdx::optional< result::insert_many > insert_many(client_session const &session, document_view_iterator_type begin, document_view_iterator_type end, options::insert const &options=options::insert())
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1236
search_index_view search_indexes()
Gets a search_index_view to the collection.
bsoncxx::v_noabi::stdx::optional< result::insert_one > insert_one(bsoncxx::v_noabi::document::view_or_value document, options::insert const &options={})
Inserts a single document into the collection. If the document is missing an identifier (_id field) o...
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, options::find_one_and_replace const &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...
cursor list_indexes(client_session const &session) const
Returns a list of the indexes currently on this collection.
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< bsoncxx::v_noabi::document::value > find_one(bsoncxx::v_noabi::document::view_or_value filter, options::find const &options=options::find())
Finds a single document in this collection that match the provided filter.
bsoncxx::v_noabi::stdx::optional< result::bulk_write > bulk_write(client_session const &session, write_model_iterator_type begin, write_model_iterator_type end, options::bulk_write const &options=options::bulk_write())
Sends writes starting at begin and ending at end to the server as a bulk write operation.
Definition collection.hpp:398
void write_concern(mongocxx::v_noabi::write_concern wc)
Sets the write_concern for this collection. Changes will not have any effect on existing write operat...
void rename(bsoncxx::v_noabi::string::view_or_value new_name, bool drop_target_before_rename=false, bsoncxx::v_noabi::stdx::optional< write_concern > const &write_concern={})
Rename this collection.
bsoncxx::v_noabi::stdx::optional< result::insert_many > insert_many(client_session const &session, container_type const &container, options::insert const &options=options::insert())
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1176
bsoncxx::v_noabi::stdx::optional< result::bulk_write > bulk_write(client_session const &session, container_type const &writes, options::bulk_write const &options=options::bulk_write())
Sends a container of writes to the server as a bulk write operation.
Definition collection.hpp:332
bsoncxx::v_noabi::stdx::optional< result::bulk_write > write(model::write const &write, options::bulk_write const &options=options::bulk_write())
Sends a write to the server as a bulk write operation.
Definition collection.hpp:243
cursor find(bsoncxx::v_noabi::document::view_or_value filter, options::find const &options=options::find())
Finds the documents in this collection which match the provided filter.
cursor list_indexes() const
Returns a list of the indexes currently on this collection.
bsoncxx::v_noabi::stdx::string_view name() const
Returns the name of this collection.
bsoncxx::v_noabi::stdx::optional< result::delete_result > delete_many(bsoncxx::v_noabi::document::view_or_value filter, options::delete_options const &options=options::delete_options())
Deletes all matching documents from the collection.
bsoncxx::v_noabi::stdx::optional< result::delete_result > delete_one(bsoncxx::v_noabi::document::view_or_value filter, options::delete_options const &options=options::delete_options())
Deletes a single matching document from the collection.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one_and_delete(bsoncxx::v_noabi::document::view_or_value filter, options::find_one_and_delete const &options=options::find_one_and_delete())
Finds a single document matching the filter, deletes it, and returns the original.
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...
change_stream watch(options::change_stream const &options={})
Gets a change stream on this collection with an empty pipeline. Change streams are only supported wit...
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, options::replace const &options=options::replace{})
Replaces a single document matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< result::bulk_write > bulk_write(write_model_iterator_type begin, write_model_iterator_type end, options::bulk_write const &options=options::bulk_write())
Sends writes starting at begin and ending at end to the server as a bulk write operation.
Definition collection.hpp:363
index_view indexes()
Gets an index_view to 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, options::update const &options=options::update())
Updates a single document matching the provided filter in this collection.
cursor distinct(bsoncxx::v_noabi::string::view_or_value name, bsoncxx::v_noabi::document::view_or_value filter, options::distinct const &options=options::distinct())
Finds the distinct values for a specified field across the collection.
bsoncxx::v_noabi::stdx::optional< result::insert_many > insert_many(document_view_iterator_type begin, document_view_iterator_type end, options::insert const &options=options::insert())
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1207
std::int64_t count_documents(bsoncxx::v_noabi::document::view_or_value filter, options::count const &options=options::count())
Counts the number of documents matching the provided filter.
collection() noexcept
Default constructs a collection object. The collection is equivalent to the state of a moved from col...
cursor aggregate(pipeline const &pipeline, options::aggregate const &options=options::aggregate())
Runs an aggregation framework pipeline against this collection.
mongocxx::v_noabi::bulk_write create_bulk_write(options::bulk_write const &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::bulk_write > bulk_write(container_type const &writes, options::bulk_write const &options=options::bulk_write())
Sends a container of writes to the server as a bulk write operation.
Definition collection.hpp:301
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, options::update const &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_update(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, options::find_one_and_update const &options=options::find_one_and_update())
Finds a single document matching the filter, updates it, and returns either the original or the newly...
std::int64_t estimated_document_count(options::estimated_document_count const &options=options::estimated_document_count())
Returns an estimate of the number of documents in the collection.
A cursor over the documents returned by a query to a MongoDB server.
Definition cursor.hpp:42
A MongoDB database.
Definition database.hpp:46
A MongoDB index.
Definition index_view.hpp:42
A MongoDB update operation that replaces a single document.
Definition replace_one.hpp:33
A single write operation for use with mongocxx::v_noabi::bulk_write.
Definition write.hpp:40
Used by MongoDB aggregation operations.
Definition aggregate.hpp:43
Used by mongocxx::v_noabi::collection.
Definition bulk_write.hpp:34
Used by change streams.
Definition change_stream.hpp:38
Used by mongocxx::v_noabi::collection::count_documents.
Definition count.hpp:39
Used by MongoDB delete operations.
Definition delete.hpp:35
Used by mongocxx::v_noabi::collection.
Definition distinct.hpp:38
Used by mongocxx::v_noabi::collection.
Definition find_one_and_delete.hpp:38
Used by mongocxx::v_noabi::collection.
Definition find_one_and_replace.hpp:39
Used by mongocxx::v_noabi::collection.
Definition find_one_and_update.hpp:40
Used by MongoDB find operations.
Definition find.hpp:40
Used by MongoDB index view operations.
Definition index_view.hpp:35
Used by mongocxx::v_noabi::collection.
Definition insert.hpp:34
Used by mongocxx::v_noabi::collection.
Definition replace.hpp:36
Used by mongocxx::v_noabi::collection.
Definition update.hpp:36
A MongoDB aggregation pipeline.
Definition pipeline.hpp:39
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:48
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:49
A MongoDB Atlas Search Index.
Definition search_index_view.hpp:26
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.
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.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
v_noabi::view_or_value< v_noabi::document::view, v_noabi::document::value > view_or_value
Equivalent to v_noabi::view_or_value<v_noabi::document::view, v_noabi::document::value>.
Definition view_or_value.hpp:30
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities representing bulk write operations.
Declares entities representing options to use with various commands.
Declares entities representing the result of various commands.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all mongocxx library entities are declared.
Provides bsoncxx::v_noabi::oid.
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 std::optional-related polyfills for library API usage.
Provides mongocxx::v_noabi::write_concern.