MongoDB C++ Driver  mongocxx-3.6.2
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
collection.hpp
1 // Copyright 2014-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 <bsoncxx/builder/basic/array.hpp>
19 #include <bsoncxx/builder/basic/document.hpp>
20 #include <bsoncxx/builder/basic/kvp.hpp>
21 #include <bsoncxx/builder/concatenate.hpp>
22 #include <bsoncxx/document/view_or_value.hpp>
23 #include <bsoncxx/oid.hpp>
24 #include <bsoncxx/stdx/optional.hpp>
25 #include <bsoncxx/string/view_or_value.hpp>
26 #include <mongocxx/bulk_write.hpp>
27 #include <mongocxx/change_stream.hpp>
28 #include <mongocxx/client_session.hpp>
29 #include <mongocxx/config/prelude.hpp>
30 #include <mongocxx/cursor.hpp>
31 #include <mongocxx/index_view.hpp>
32 #include <mongocxx/model/insert_one.hpp>
33 #include <mongocxx/options/aggregate.hpp>
34 #include <mongocxx/options/bulk_write.hpp>
35 #include <mongocxx/options/change_stream.hpp>
36 #include <mongocxx/options/count.hpp>
37 #include <mongocxx/options/delete.hpp>
38 #include <mongocxx/options/distinct.hpp>
39 #include <mongocxx/options/estimated_document_count.hpp>
40 #include <mongocxx/options/find.hpp>
41 #include <mongocxx/options/find_one_and_delete.hpp>
42 #include <mongocxx/options/find_one_and_replace.hpp>
43 #include <mongocxx/options/find_one_and_update.hpp>
44 #include <mongocxx/options/index.hpp>
45 #include <mongocxx/options/index_view.hpp>
46 #include <mongocxx/options/insert.hpp>
47 #include <mongocxx/options/replace.hpp>
48 #include <mongocxx/options/update.hpp>
49 #include <mongocxx/pipeline.hpp>
50 #include <mongocxx/read_concern.hpp>
51 #include <mongocxx/read_preference.hpp>
52 #include <mongocxx/result/bulk_write.hpp>
53 #include <mongocxx/result/delete.hpp>
54 #include <mongocxx/result/insert_many.hpp>
55 #include <mongocxx/result/insert_one.hpp>
56 #include <mongocxx/result/replace_one.hpp>
57 #include <mongocxx/result/update.hpp>
58 #include <mongocxx/write_concern.hpp>
59 #include <string>
60 
61 namespace mongocxx {
62 MONGOCXX_INLINE_NAMESPACE_BEGIN
63 
64 class client;
65 class database;
66 
81 class MONGOCXX_API collection {
82  //
83  // Utility class supporting the convenience of {} meaning an empty bsoncxx::document.
84  //
85  // Users may not use this class directly.
86  //
87  // In places where driver methods take this class as a parameter, passing {} will
88  // translate to a default-constructed bsoncxx::document::view_or_value,
89  // regardless of other overloads taking other default-constructible types
90  // for that parameter. This class avoids compiler ambiguity with such overloads.
91  //
92  // See collection::update_one for an example of such overloads.
93  //
94  class _empty_doc_tag {
95  _empty_doc_tag() = default;
96  };
97 
98  public:
105  collection() noexcept;
106 
110  collection(collection&&) noexcept;
111 
115  collection& operator=(collection&&) noexcept;
116 
121 
125  collection& operator=(const collection&);
126 
131 
136  explicit operator bool() const noexcept;
137 
159  cursor aggregate(const pipeline& pipeline,
160  const options::aggregate& options = options::aggregate());
161 
183  cursor aggregate(const client_session& session,
184  const pipeline& pipeline,
185  const options::aggregate& options = options::aggregate());
189 
202  class bulk_write create_bulk_write(const options::bulk_write& options = {});
203 
216  class bulk_write create_bulk_write(const client_session& session,
217  const options::bulk_write& options = {});
221 
244  MONGOCXX_INLINE stdx::optional<result::bulk_write> write(
245  const model::write& write, const options::bulk_write& options = options::bulk_write());
246 
269  MONGOCXX_INLINE stdx::optional<result::bulk_write> write(
270  const client_session& session,
271  const model::write& write,
272  const options::bulk_write& options = options::bulk_write());
276 
300  template <typename container_type>
301  MONGOCXX_INLINE stdx::optional<result::bulk_write> bulk_write(
302  const container_type& writes, const options::bulk_write& options = options::bulk_write());
303 
327  template <typename container_type>
328  MONGOCXX_INLINE stdx::optional<result::bulk_write> bulk_write(
329  const client_session& session,
330  const container_type& writes,
331  const options::bulk_write& options = options::bulk_write());
335 
360  template <typename write_model_iterator_type>
361  MONGOCXX_INLINE stdx::optional<result::bulk_write> bulk_write(
362  write_model_iterator_type begin,
363  write_model_iterator_type end,
364  const options::bulk_write& options = options::bulk_write());
365 
390  template <typename write_model_iterator_type>
391  MONGOCXX_INLINE stdx::optional<result::bulk_write> bulk_write(
392  const client_session& session,
393  write_model_iterator_type begin,
394  write_model_iterator_type end,
395  const options::bulk_write& options = options::bulk_write());
399 
415  const options::count& options = options::count());
416 
431  std::int64_t count_documents(const client_session& session,
433  const options::count& options = options::count());
437 
455 
479  bsoncxx::document::view_or_value index_options = {},
480  options::index_view operation_options = options::index_view{});
481 
504  const client_session& session,
506  bsoncxx::document::view_or_value index_options = {},
507  options::index_view operation_options = options::index_view{});
508 
512 
531  stdx::optional<result::delete_result> delete_many(
534 
553  stdx::optional<result::delete_result> delete_many(
554  const client_session& session,
557 
561 
580  stdx::optional<result::delete_result> delete_one(
583 
602  stdx::optional<result::delete_result> delete_one(
603  const client_session& session,
606 
610 
622 
626 
631  const options::distinct& options = options::distinct());
632 
644 
648 
654  const options::distinct& options = options::distinct());
655 
659 
678  void drop(const bsoncxx::stdx::optional<mongocxx::write_concern>& write_concern = {});
679 
698  void drop(const client_session& session,
699  const bsoncxx::stdx::optional<mongocxx::write_concern>& write_concern = {});
700 
704 
725  const options::find& options = options::find());
726 
746  cursor find(const client_session& session,
748  const options::find& options = options::find());
749 
766  stdx::optional<bsoncxx::document::value> find_one(
768 
785  stdx::optional<bsoncxx::document::value> find_one(
786  const client_session& session,
788  const options::find& options = options::find());
789 
793 
813  stdx::optional<bsoncxx::document::value> find_one_and_delete(
816 
836  stdx::optional<bsoncxx::document::value> find_one_and_delete(
837  const client_session& session,
840 
844 
867  stdx::optional<bsoncxx::document::value> find_one_and_replace(
871 
894  stdx::optional<bsoncxx::document::value> find_one_and_replace(
895  const client_session& session,
899 
903 
926  stdx::optional<bsoncxx::document::value> find_one_and_update(
930 
951  stdx::optional<bsoncxx::document::value> find_one_and_update(
953  const pipeline& update,
955 
976  stdx::optional<bsoncxx::document::value> find_one_and_update(
978  std::initializer_list<_empty_doc_tag> update,
980 
1003  stdx::optional<bsoncxx::document::value> find_one_and_update(
1004  const client_session& session,
1008 
1031  stdx::optional<bsoncxx::document::value> find_one_and_update(
1032  const client_session& session,
1034  const pipeline& update,
1036 
1059  stdx::optional<bsoncxx::document::value> find_one_and_update(
1060  const client_session& session,
1062  std::initializer_list<_empty_doc_tag> update,
1064 
1068 
1085  stdx::optional<result::insert_one> insert_one(bsoncxx::document::view_or_value document,
1086  const options::insert& options = {});
1103  stdx::optional<result::insert_one> insert_one(const client_session& session,
1105  const options::insert& options = {});
1109 
1135  template <typename container_type>
1136  MONGOCXX_INLINE stdx::optional<result::insert_many> insert_many(
1137  const container_type& container, const options::insert& options = options::insert());
1138 
1160  template <typename container_type>
1161  MONGOCXX_INLINE stdx::optional<result::insert_many> insert_many(
1162  const client_session& session,
1163  const container_type& container,
1164  const options::insert& options = options::insert());
1165 
1191  template <typename document_view_iterator_type>
1192  MONGOCXX_INLINE stdx::optional<result::insert_many> insert_many(
1193  document_view_iterator_type begin,
1194  document_view_iterator_type end,
1195  const options::insert& options = options::insert());
1196 
1218  template <typename document_view_iterator_type>
1219  MONGOCXX_INLINE stdx::optional<result::insert_many> insert_many(
1220  const client_session& session,
1221  document_view_iterator_type begin,
1222  document_view_iterator_type end,
1223  const options::insert& options = options::insert());
1227 
1240 
1253  cursor list_indexes(const client_session& session) const;
1254 
1258 
1265  stdx::string_view name() const;
1266 
1287  bool drop_target_before_rename = false,
1288  const bsoncxx::stdx::optional<write_concern>& write_concern = {});
1289 
1311  void rename(const client_session& session,
1313  bool drop_target_before_rename = false,
1314  const bsoncxx::stdx::optional<write_concern>& write_concern = {});
1315 
1319 
1329  void read_concern(class read_concern rc);
1330 
1339  class read_concern read_concern() const;
1340 
1351 
1359  class read_preference read_preference() const;
1360 
1383  stdx::optional<result::replace_one> replace_one(
1386  const options::replace& options = options::replace{});
1387 
1410  stdx::optional<result::replace_one> replace_one(
1411  const client_session& session,
1414  const options::replace& options = options::replace{});
1415 
1438  stdx::optional<result::update> update_many(bsoncxx::document::view_or_value filter,
1440  const options::update& options = options::update());
1441 
1462  stdx::optional<result::update> update_many(bsoncxx::document::view_or_value filter,
1463  const pipeline& update,
1464  const options::update& options = options::update());
1465 
1486  stdx::optional<result::update> update_many(bsoncxx::document::view_or_value filter,
1487  std::initializer_list<_empty_doc_tag> update,
1488  const options::update& options = options::update());
1489 
1512  stdx::optional<result::update> update_many(const client_session& session,
1515  const options::update& options = options::update());
1516 
1539  stdx::optional<result::update> update_many(const client_session& session,
1541  const pipeline& update,
1542  const options::update& options = options::update());
1543 
1566  stdx::optional<result::update> update_many(const client_session& session,
1568  std::initializer_list<_empty_doc_tag> update,
1569  const options::update& options = options::update());
1570 
1574 
1597  stdx::optional<result::update> update_one(bsoncxx::document::view_or_value filter,
1599  const options::update& options = options::update());
1600 
1621  stdx::optional<result::update> update_one(bsoncxx::document::view_or_value filter,
1622  const pipeline& update,
1623  const options::update& options = options::update());
1624 
1645  stdx::optional<result::update> update_one(bsoncxx::document::view_or_value filter,
1646  std::initializer_list<_empty_doc_tag> update,
1647  const options::update& options = options::update());
1648 
1671  stdx::optional<result::update> update_one(const client_session& session,
1674  const options::update& options = options::update());
1675 
1698  stdx::optional<result::update> update_one(const client_session& session,
1700  const pipeline& update,
1701  const options::update& options = options::update());
1702 
1725  stdx::optional<result::update> update_one(const client_session& session,
1727  std::initializer_list<_empty_doc_tag> update,
1728  const options::update& options = options::update());
1729 
1733 
1742 
1748  class write_concern write_concern() const;
1749 
1753 
1769 
1781  change_stream watch(const client_session& session, const options::change_stream& options = {});
1782 
1799  change_stream watch(const pipeline& pipe, const options::change_stream& options = {});
1800 
1817  const pipeline& pipe,
1818  const options::change_stream& options = {});
1819 
1823 
1824  private:
1825  friend class bulk_write;
1826  friend class database;
1827 
1828  MONGOCXX_PRIVATE collection(const database& database,
1829  bsoncxx::string::view_or_value collection_name);
1830 
1831  MONGOCXX_PRIVATE collection(const database& database, void* collection);
1832 
1833  MONGOCXX_PRIVATE cursor _aggregate(const client_session* session,
1834  const pipeline& pipeline,
1835  const options::aggregate& options);
1836 
1837  MONGOCXX_PRIVATE std::int64_t _count(const client_session* session,
1839  const options::count& options);
1840 
1841  MONGOCXX_PRIVATE std::int64_t _count_documents(const client_session* session,
1843  const options::count& options);
1844 
1845  MONGOCXX_PRIVATE bsoncxx::document::value _create_index(
1846  const client_session* session,
1848  bsoncxx::document::view_or_value index_options,
1849  options::index_view operation_options);
1850 
1851  MONGOCXX_PRIVATE stdx::optional<result::delete_result> _delete_many(
1852  const client_session* session,
1854  const options::delete_options& options);
1855 
1856  MONGOCXX_PRIVATE stdx::optional<result::delete_result> _delete_one(
1857  const client_session* session,
1859  const options::delete_options& options);
1860 
1861  MONGOCXX_PRIVATE cursor _distinct(const client_session* session,
1864  const options::distinct& options);
1865 
1866  MONGOCXX_PRIVATE void _drop(
1867  const client_session* session,
1868  const bsoncxx::stdx::optional<mongocxx::write_concern>& write_concern);
1869 
1870  MONGOCXX_PRIVATE cursor _find(const client_session* session,
1872  const options::find& options);
1873 
1874  MONGOCXX_PRIVATE stdx::optional<bsoncxx::document::value> _find_one(
1875  const client_session* session,
1877  const options::find& options);
1878 
1879  MONGOCXX_PRIVATE stdx::optional<bsoncxx::document::value> _find_one_and_delete(
1880  const client_session* session,
1882  const options::find_one_and_delete& options);
1883 
1884  MONGOCXX_PRIVATE stdx::optional<bsoncxx::document::value> _find_one_and_replace(
1885  const client_session* session,
1888  const options::find_one_and_replace& options);
1889 
1890  MONGOCXX_PRIVATE stdx::optional<bsoncxx::document::value> _find_one_and_update(
1891  const client_session* session,
1894  const options::find_one_and_update& options);
1895 
1896  MONGOCXX_PRIVATE stdx::optional<result::insert_one> _insert_one(
1897  const client_session* session,
1899  const options::insert& options);
1900 
1901  MONGOCXX_PRIVATE void _rename(
1902  const client_session* session,
1904  bool drop_target_before_rename,
1905  const bsoncxx::stdx::optional<class write_concern>& write_concern);
1906 
1907  MONGOCXX_PRIVATE stdx::optional<result::replace_one> _replace_one(
1908  const client_session* session,
1909  const options::bulk_write& bulk_opts,
1910  const model::replace_one& replace_op);
1911 
1912  MONGOCXX_PRIVATE stdx::optional<result::replace_one> _replace_one(
1913  const client_session* session,
1916  const options::replace& options);
1917 
1918  MONGOCXX_PRIVATE stdx::optional<result::update> _update_one(
1919  const client_session* session,
1922  const options::update& options);
1923 
1924  MONGOCXX_PRIVATE stdx::optional<result::update> _update_many(
1925  const client_session* session,
1928  const options::update& options);
1929 
1930  MONGOCXX_PRIVATE change_stream _watch(const client_session* session,
1931  const pipeline& pipe,
1932  const options::change_stream& options);
1933 
1934  // Helpers for the insert_many method templates.
1935  class bulk_write _init_insert_many(const options::insert& options,
1936  const client_session* session);
1937 
1938  void _insert_many_doc_handler(class bulk_write& writes,
1939  bsoncxx::builder::basic::array& inserted_ids,
1940  bsoncxx::document::view doc) const;
1941 
1942  stdx::optional<result::insert_many> _exec_insert_many(
1943  class bulk_write& writes, bsoncxx::builder::basic::array& inserted_ids);
1944 
1945  template <typename document_view_iterator_type>
1946  MONGOCXX_PRIVATE stdx::optional<result::insert_many> _insert_many(
1947  const client_session* session,
1948  document_view_iterator_type begin,
1949  document_view_iterator_type end,
1950  const options::insert& options);
1951 
1952  class MONGOCXX_PRIVATE impl;
1953 
1954  MONGOCXX_PRIVATE impl& _get_impl();
1955  MONGOCXX_PRIVATE const impl& _get_impl() const;
1956 
1957  std::unique_ptr<impl> _impl;
1958 };
1959 
1960 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::write(
1961  const model::write& write, const options::bulk_write& options) {
1962  return create_bulk_write(options).append(write).execute();
1963 }
1964 
1965 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::write(
1966  const client_session& session, const model::write& write, const options::bulk_write& options) {
1967  return create_bulk_write(session, options).append(write).execute();
1968 }
1969 
1970 template <typename container_type>
1971 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::bulk_write(
1972  const container_type& requests, const options::bulk_write& options) {
1973  return bulk_write(requests.begin(), requests.end(), options);
1974 }
1975 
1976 template <typename container_type>
1977 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::bulk_write(
1978  const client_session& session,
1979  const container_type& requests,
1980  const options::bulk_write& options) {
1981  return bulk_write(session, requests.begin(), requests.end(), options);
1982 }
1983 
1984 template <typename write_model_iterator_type>
1985 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::bulk_write(
1986  write_model_iterator_type begin,
1987  write_model_iterator_type end,
1988  const options::bulk_write& options) {
1989  auto writes = create_bulk_write(options);
1990  std::for_each(begin, end, [&](const model::write& current) { writes.append(current); });
1991  return writes.execute();
1992 }
1993 
1994 template <typename write_model_iterator_type>
1995 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::bulk_write(
1996  const client_session& session,
1997  write_model_iterator_type begin,
1998  write_model_iterator_type end,
1999  const options::bulk_write& options) {
2000  auto writes = create_bulk_write(session, options);
2001  std::for_each(begin, end, [&](const model::write& current) { writes.append(current); });
2002  return writes.execute();
2003 }
2004 
2005 template <typename container_type>
2006 MONGOCXX_INLINE stdx::optional<result::insert_many> collection::insert_many(
2007  const container_type& container, const options::insert& options) {
2008  return insert_many(container.begin(), container.end(), options);
2009 }
2010 
2011 template <typename container_type>
2012 MONGOCXX_INLINE stdx::optional<result::insert_many> collection::insert_many(
2013  const client_session& session,
2014  const container_type& container,
2015  const options::insert& options) {
2016  return insert_many(session, container.begin(), container.end(), options);
2017 }
2018 
2019 template <typename document_view_iterator_type>
2020 MONGOCXX_INLINE stdx::optional<result::insert_many> collection::_insert_many(
2021 
2022  const client_session* session,
2023  document_view_iterator_type begin,
2024  document_view_iterator_type end,
2025  const options::insert& options) {
2026  bsoncxx::builder::basic::array inserted_ids;
2027  auto writes = _init_insert_many(options, session);
2028  std::for_each(begin, end, [&inserted_ids, &writes, this](bsoncxx::document::view doc) {
2029  _insert_many_doc_handler(writes, inserted_ids, doc);
2030  });
2031  return _exec_insert_many(writes, inserted_ids);
2032 }
2033 
2034 template <typename document_view_iterator_type>
2035 MONGOCXX_INLINE stdx::optional<result::insert_many> collection::insert_many(
2036  document_view_iterator_type begin,
2037  document_view_iterator_type end,
2038  const options::insert& options) {
2039  return _insert_many(nullptr, begin, end, options);
2040 }
2041 
2042 template <typename document_view_iterator_type>
2043 MONGOCXX_INLINE stdx::optional<result::insert_many> collection::insert_many(
2044  const client_session& session,
2045  document_view_iterator_type begin,
2046  document_view_iterator_type end,
2047  const options::insert& options) {
2048  return _insert_many(&session, begin, end, options);
2049 }
2050 
2051 MONGOCXX_INLINE_NAMESPACE_END
2052 } // namespace mongocxx
2053 
2054 #include <mongocxx/config/postlude.hpp>
mongocxx::collection::watch
change_stream watch(const client_session &session, const pipeline &pipe, const options::change_stream &options={})
Gets a change stream on this collection.
mongocxx::collection::update_many
stdx::optional< result::update > update_many(bsoncxx::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, const options::update &options=options::update())
Updates multiple documents matching the provided filter in this collection.
mongocxx::collection::write
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:1960
mongocxx::collection::delete_one
stdx::optional< result::delete_result > delete_one(const client_session &session, bsoncxx::document::view_or_value filter, const options::delete_options &options=options::delete_options())
Deletes a single matching document from the collection.
mongocxx::collection::update_many
stdx::optional< result::update > update_many(const client_session &session, bsoncxx::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, const options::update &options=options::update())
Updates multiple documents matching the provided filter in this collection.
mongocxx::collection::drop
void drop(const bsoncxx::stdx::optional< mongocxx::write_concern > &write_concern={})
Drops this collection and all its contained documents from the database.
mongocxx::change_stream
Definition: change_stream.hpp:31
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::collection::watch
change_stream watch(const options::change_stream &options={})
Gets a change stream on this collection with an empty pipeline.
mongocxx::collection::update_one
stdx::optional< result::update > update_one(const client_session &session, bsoncxx::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, const options::update &options=options::update())
Updates a single document matching the provided filter in this collection.
bsoncxx::view_or_value< document::view, document::value >
mongocxx::collection::insert_one
stdx::optional< result::insert_one > insert_one(bsoncxx::document::view_or_value document, const options::insert &options={})
Inserts a single document into the collection.
mongocxx::options::aggregate
Class representing the optional arguments to a MongoDB aggregation operation.
Definition: aggregate.hpp:38
mongocxx::options::insert
Class representing the optional arguments to a MongoDB insert operation.
Definition: insert.hpp:31
mongocxx::options::estimated_document_count
Class representing the optional arguments to mongocxx::collection::estimated_document_count.
Definition: estimated_document_count.hpp:32
mongocxx::write_concern
Class representing the server-side requirement for reporting the success of a write operation.
Definition: write_concern.hpp:56
mongocxx::collection::watch
change_stream watch(const pipeline &pipe, const options::change_stream &options={})
Gets a change stream on this collection.
mongocxx::collection::collection
collection() noexcept
Default constructs a collection object.
mongocxx::collection::distinct
cursor distinct(bsoncxx::string::view_or_value name, bsoncxx::document::view_or_value filter, const options::distinct &options=options::distinct())
Finds the distinct values for a specified field across the collection.
mongocxx::collection::replace_one
stdx::optional< result::replace_one > replace_one(bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value replacement, const options::replace &options=options::replace{})
Replaces a single document matching the provided filter in this collection.
mongocxx::options::find_one_and_delete
Class representing the optional arguments to a MongoDB find_and_modify delete operation.
Definition: find_one_and_delete.hpp:34
mongocxx::collection::watch
change_stream watch(const client_session &session, const options::change_stream &options={})
mongocxx::collection::name
stdx::string_view name() const
Returns the name of this collection.
mongocxx::collection::indexes
index_view indexes()
Gets an index_view to the collection.
mongocxx::collection::list_indexes
cursor list_indexes(const client_session &session) const
Returns a list of the indexes currently on this collection.
mongocxx::options::distinct
Class representing the optional arguments to a MongoDB distinct command.
Definition: distinct.hpp:34
mongocxx::collection::update_one
stdx::optional< result::update > update_one(bsoncxx::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, const options::update &options=options::update())
Updates a single document matching the provided filter in this collection.
mongocxx::collection::count_documents
std::int64_t count_documents(const client_session &session, bsoncxx::document::view_or_value filter, const options::count &options=options::count())
Counts the number of documents matching the provided filter.
mongocxx::options::index_view
Class representing optional arguments to IndexView operations.
Definition: index_view.hpp:31
mongocxx::collection::write_concern
class write_concern write_concern() const
Gets the write_concern for the collection.
mongocxx::collection::find_one
stdx::optional< bsoncxx::document::value > find_one(const client_session &session, bsoncxx::document::view_or_value filter, const options::find &options=options::find())
Finds a single document in this collection that match the provided filter.
mongocxx::read_concern
A class to represent the read concern.
Definition: read_concern.hpp:54
mongocxx::collection::update_one
stdx::optional< result::update > update_one(bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value update, const options::update &options=options::update())
Updates a single document matching the provided filter in this collection.
mongocxx::collection::delete_many
stdx::optional< result::delete_result > delete_many(bsoncxx::document::view_or_value filter, const options::delete_options &options=options::delete_options())
Deletes all matching documents from the collection.
mongocxx::collection::insert_many
stdx::optional< result::insert_many > insert_many(const container_type &container, const options::insert &options=options::insert())
Inserts multiple documents into the collection.
Definition: collection.hpp:2006
bsoncxx::document::value
A read-only BSON document that owns its underlying buffer.
Definition: value.hpp:33
mongocxx::collection::find_one_and_update
stdx::optional< bsoncxx::document::value > find_one_and_update(bsoncxx::document::view_or_value filter, const pipeline &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...
mongocxx::collection::read_concern
class read_concern read_concern() const
Gets the read_concern for the collection.
mongocxx::model::write
Models a single write operation within a mongocxx::bulk_write.
Definition: write.hpp:37
mongocxx::read_preference
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:62
mongocxx::collection::count_documents
std::int64_t count_documents(bsoncxx::document::view_or_value filter, const options::count &options=options::count())
Counts the number of documents matching the provided filter.
mongocxx::collection::find_one_and_update
stdx::optional< bsoncxx::document::value > find_one_and_update(bsoncxx::document::view_or_value filter, std::initializer_list< _empty_doc_tag > 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...
bsoncxx::string::view_or_value
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:36
mongocxx::options::find_one_and_update
Class representing the optional arguments to a MongoDB find_and_modify update operation.
Definition: find_one_and_update.hpp:37
mongocxx::collection::find_one
stdx::optional< bsoncxx::document::value > find_one(bsoncxx::document::view_or_value filter, const options::find &options=options::find())
Finds a single document in this collection that match the provided filter.
mongocxx::collection::replace_one
stdx::optional< result::replace_one > replace_one(const client_session &session, bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value replacement, const options::replace &options=options::replace{})
Replaces a single document matching the provided filter in this collection.
mongocxx::collection::delete_one
stdx::optional< result::delete_result > delete_one(bsoncxx::document::view_or_value filter, const options::delete_options &options=options::delete_options())
Deletes a single matching document from the collection.
mongocxx::collection::delete_many
stdx::optional< result::delete_result > delete_many(const client_session &session, bsoncxx::document::view_or_value filter, const options::delete_options &options=options::delete_options())
Deletes all matching documents from the collection.
mongocxx::options::find
Class representing the optional arguments to a MongoDB query.
Definition: find.hpp:36
mongocxx::index_view
Definition: index_view.hpp:32
mongocxx::collection::update_many
stdx::optional< result::update > update_many(bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value update, const options::update &options=options::update())
Updates multiple documents matching the provided filter in this collection.
mongocxx::collection::find_one_and_replace
stdx::optional< bsoncxx::document::value > find_one_and_replace(bsoncxx::document::view_or_value filter, bsoncxx::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...
mongocxx::collection::estimated_document_count
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.
mongocxx::collection::update_many
stdx::optional< result::update > update_many(bsoncxx::document::view_or_value filter, const pipeline &update, const options::update &options=options::update())
Updates multiple documents matching the provided filter in this collection.
mongocxx::collection::find_one_and_delete
stdx::optional< bsoncxx::document::value > find_one_and_delete(bsoncxx::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.
mongocxx::collection::update_one
stdx::optional< result::update > update_one(const client_session &session, bsoncxx::document::view_or_value filter, const pipeline &update, const options::update &options=options::update())
Updates a single document matching the provided filter in this collection.
mongocxx::collection::insert_one
stdx::optional< result::insert_one > insert_one(const client_session &session, bsoncxx::document::view_or_value document, const options::insert &options={})
Inserts a single document into the collection.
mongocxx::options::update
Class representing the optional arguments to a MongoDB update operation.
Definition: update.hpp:33
mongocxx::collection::rename
void rename(const client_session &session, bsoncxx::string::view_or_value new_name, bool drop_target_before_rename=false, const bsoncxx::stdx::optional< write_concern > &write_concern={})
Rename this collection.
mongocxx::collection::find_one_and_update
stdx::optional< bsoncxx::document::value > find_one_and_update(bsoncxx::document::view_or_value filter, bsoncxx::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...
mongocxx::pipeline
Class representing a MongoDB aggregation pipeline.
Definition: pipeline.hpp:38
bsoncxx::builder::basic::array
A traditional builder-style interface for constructing a BSON array.
Definition: array.hpp:35
mongocxx::options::change_stream
Definition: change_stream.hpp:35
mongocxx::client_session
Use a session for a sequence of operations, optionally with causal consistency.
Definition: client_session.hpp:39
mongocxx::bulk_write
Class representing a batch of write operations that can be sent to the server as a group.
Definition: bulk_write.hpp:43
mongocxx::collection::find
cursor find(const client_session &session, bsoncxx::document::view_or_value filter, const options::find &options=options::find())
Finds the documents in this collection which match the provided filter.
mongocxx::database
Class representing a MongoDB database.
Definition: database.hpp:43
mongocxx::collection::find
cursor find(bsoncxx::document::view_or_value filter, const options::find &options=options::find())
Finds the documents in this collection which match the provided filter.
mongocxx::collection::update_many
stdx::optional< result::update > update_many(const client_session &session, bsoncxx::document::view_or_value filter, const pipeline &update, const options::update &options=options::update())
Updates multiple documents matching the provided filter in this collection.
mongocxx::collection::update_one
stdx::optional< result::update > update_one(bsoncxx::document::view_or_value filter, const pipeline &update, const options::update &options=options::update())
Updates a single document matching the provided filter in this collection.
mongocxx::collection::find_one_and_update
stdx::optional< bsoncxx::document::value > find_one_and_update(const client_session &session, bsoncxx::document::view_or_value filter, std::initializer_list< _empty_doc_tag > 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...
mongocxx::collection::find_one_and_update
stdx::optional< bsoncxx::document::value > find_one_and_update(const client_session &session, bsoncxx::document::view_or_value filter, const pipeline &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...
mongocxx::collection::find_one_and_delete
stdx::optional< bsoncxx::document::value > find_one_and_delete(const client_session &session, bsoncxx::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.
mongocxx::options::delete_options
Class representing the optional arguments to a MongoDB delete operation.
Definition: delete.hpp:31
mongocxx::collection
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:81
mongocxx::model::replace_one
Class representing a MongoDB update operation that replaces a single document.
Definition: replace_one.hpp:31
mongocxx::collection::create_index
bsoncxx::document::value create_index(const client_session &session, bsoncxx::document::view_or_value keys, bsoncxx::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.
mongocxx::collection::update_one
stdx::optional< result::update > update_one(const client_session &session, bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value update, const options::update &options=options::update())
Updates a single document matching the provided filter in this collection.
mongocxx::options::replace
Class representing the optional arguments to a MongoDB replace operation.
Definition: replace.hpp:33
mongocxx::collection::find_one_and_update
stdx::optional< bsoncxx::document::value > find_one_and_update(const client_session &session, bsoncxx::document::view_or_value filter, bsoncxx::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...
mongocxx::collection::drop
void drop(const client_session &session, const bsoncxx::stdx::optional< mongocxx::write_concern > &write_concern={})
Drops this collection and all its contained documents from the database.
mongocxx::options::bulk_write
Class representing the optional arguments to a MongoDB bulk write.
Definition: bulk_write.hpp:29
mongocxx::options::find_one_and_replace
Class representing the optional arguments to a MongoDB find_and_modify replace operation.
Definition: find_one_and_replace.hpp:36
mongocxx::collection::update_many
stdx::optional< result::update > update_many(const client_session &session, bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value update, const options::update &options=options::update())
Updates multiple documents matching the provided filter in this collection.
mongocxx::options::count
Class representing the optional arguments to mongocxx::collection::count_documents.
Definition: count.hpp:36
mongocxx::cursor
Class representing a pointer to the result set of a query on a MongoDB server.
Definition: cursor.hpp:36
mongocxx::collection::read_preference
class read_preference read_preference() const
Gets the read_preference for the collection.
mongocxx::collection::list_indexes
cursor list_indexes() const
Returns a list of the indexes currently on this collection.
mongocxx::collection::create_index
bsoncxx::document::value create_index(bsoncxx::document::view_or_value keys, bsoncxx::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::document::view
A read-only, non-owning view of a BSON document.
Definition: view.hpp:33
mongocxx::collection::distinct
cursor distinct(const client_session &session, bsoncxx::string::view_or_value name, bsoncxx::document::view_or_value filter, const options::distinct &options=options::distinct())
Finds the distinct values for a specified field across the collection.
mongocxx::collection::rename
void rename(bsoncxx::string::view_or_value new_name, bool drop_target_before_rename=false, const bsoncxx::stdx::optional< write_concern > &write_concern={})
Rename this collection.
mongocxx::collection::find_one_and_replace
stdx::optional< bsoncxx::document::value > find_one_and_replace(const client_session &session, bsoncxx::document::view_or_value filter, bsoncxx::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...