20 #include <bsoncxx/builder/basic/array.hpp>
21 #include <bsoncxx/builder/basic/document.hpp>
22 #include <bsoncxx/builder/basic/kvp.hpp>
23 #include <bsoncxx/builder/concatenate.hpp>
24 #include <bsoncxx/document/view_or_value.hpp>
25 #include <bsoncxx/oid.hpp>
26 #include <bsoncxx/stdx/optional.hpp>
27 #include <bsoncxx/string/view_or_value.hpp>
28 #include <mongocxx/bulk_write.hpp>
29 #include <mongocxx/change_stream.hpp>
30 #include <mongocxx/client_session.hpp>
31 #include <mongocxx/cursor.hpp>
32 #include <mongocxx/index_view.hpp>
33 #include <mongocxx/model/insert_one.hpp>
34 #include <mongocxx/options/aggregate.hpp>
35 #include <mongocxx/options/bulk_write.hpp>
36 #include <mongocxx/options/change_stream.hpp>
37 #include <mongocxx/options/count.hpp>
38 #include <mongocxx/options/delete.hpp>
39 #include <mongocxx/options/distinct.hpp>
40 #include <mongocxx/options/estimated_document_count.hpp>
41 #include <mongocxx/options/find.hpp>
42 #include <mongocxx/options/find_one_and_delete.hpp>
43 #include <mongocxx/options/find_one_and_replace.hpp>
44 #include <mongocxx/options/find_one_and_update.hpp>
45 #include <mongocxx/options/index.hpp>
46 #include <mongocxx/options/index_view.hpp>
47 #include <mongocxx/options/insert.hpp>
48 #include <mongocxx/options/replace.hpp>
49 #include <mongocxx/options/update.hpp>
50 #include <mongocxx/pipeline.hpp>
51 #include <mongocxx/read_concern.hpp>
52 #include <mongocxx/read_preference.hpp>
53 #include <mongocxx/result/bulk_write.hpp>
54 #include <mongocxx/result/delete.hpp>
55 #include <mongocxx/result/insert_many.hpp>
56 #include <mongocxx/result/insert_one.hpp>
57 #include <mongocxx/result/replace_one.hpp>
58 #include <mongocxx/result/update.hpp>
59 #include <mongocxx/write_concern.hpp>
61 #include <mongocxx/config/prelude.hpp>
64 MONGOCXX_INLINE_NAMESPACE_BEGIN
96 class _empty_doc_tag {
97 _empty_doc_tag() =
default;
138 explicit operator bool()
const noexcept;
246 MONGOCXX_INLINE stdx::optional<result::bulk_write> write(
271 MONGOCXX_INLINE stdx::optional<result::bulk_write> write(
302 template <
typename container_type>
303 MONGOCXX_INLINE stdx::optional<result::bulk_write>
bulk_write(
329 template <
typename container_type>
330 MONGOCXX_INLINE stdx::optional<result::bulk_write>
bulk_write(
332 const container_type& writes,
362 template <
typename write_model_iterator_type>
363 MONGOCXX_INLINE stdx::optional<result::bulk_write>
bulk_write(
364 write_model_iterator_type begin,
365 write_model_iterator_type end,
392 template <
typename write_model_iterator_type>
393 MONGOCXX_INLINE stdx::optional<result::bulk_write>
bulk_write(
395 write_model_iterator_type begin,
396 write_model_iterator_type end,
474 std::int64_t estimated_document_count(
555 stdx::optional<result::delete_result> delete_many(
577 stdx::optional<result::delete_result> delete_many(
604 stdx::optional<result::delete_result> delete_one(
626 stdx::optional<result::delete_result> delete_one(
702 void drop(
const bsoncxx::stdx::optional<mongocxx::write_concern>&
write_concern = {});
723 const bsoncxx::stdx::optional<mongocxx::write_concern>&
write_concern = {});
790 stdx::optional<bsoncxx::document::value> find_one(
809 stdx::optional<bsoncxx::document::value> find_one(
837 stdx::optional<bsoncxx::document::value> find_one_and_delete(
860 stdx::optional<bsoncxx::document::value> find_one_and_delete(
891 stdx::optional<bsoncxx::document::value> find_one_and_replace(
918 stdx::optional<bsoncxx::document::value> find_one_and_replace(
950 stdx::optional<bsoncxx::document::value> find_one_and_update(
975 stdx::optional<bsoncxx::document::value> find_one_and_update(
1000 stdx::optional<bsoncxx::document::value> find_one_and_update(
1002 std::initializer_list<_empty_doc_tag> update,
1027 stdx::optional<bsoncxx::document::value> find_one_and_update(
1055 stdx::optional<bsoncxx::document::value> find_one_and_update(
1083 stdx::optional<bsoncxx::document::value> find_one_and_update(
1086 std::initializer_list<_empty_doc_tag> update,
1127 stdx::optional<result::insert_one> insert_one(
const client_session& session,
1159 template <
typename container_type>
1160 MONGOCXX_INLINE stdx::optional<result::insert_many> insert_many(
1184 template <
typename container_type>
1185 MONGOCXX_INLINE stdx::optional<result::insert_many> insert_many(
1187 const container_type& container,
1215 template <
typename document_view_iterator_type>
1216 MONGOCXX_INLINE stdx::optional<result::insert_many> insert_many(
1217 document_view_iterator_type begin,
1218 document_view_iterator_type end,
1242 template <
typename document_view_iterator_type>
1243 MONGOCXX_INLINE stdx::optional<result::insert_many> insert_many(
1245 document_view_iterator_type begin,
1246 document_view_iterator_type end,
1263 cursor list_indexes()
const;
1289 stdx::string_view name()
const;
1311 bool drop_target_before_rename =
false,
1312 const bsoncxx::stdx::optional<write_concern>&
write_concern = {});
1337 bool drop_target_before_rename =
false,
1338 const bsoncxx::stdx::optional<write_concern>&
write_concern = {});
1407 stdx::optional<result::replace_one> replace_one(
1434 stdx::optional<result::replace_one> replace_one(
1511 std::initializer_list<_empty_doc_tag> update,
1536 stdx::optional<result::update> update_many(
const client_session& session,
1563 stdx::optional<result::update> update_many(
const client_session& session,
1590 stdx::optional<result::update> update_many(
const client_session& session,
1592 std::initializer_list<_empty_doc_tag> update,
1670 std::initializer_list<_empty_doc_tag> update,
1695 stdx::optional<result::update> update_one(
const client_session& session,
1722 stdx::optional<result::update> update_one(
const client_session& session,
1749 stdx::optional<result::update> update_one(
const client_session& session,
1751 std::initializer_list<_empty_doc_tag> update,
1861 MONGOCXX_PRIVATE std::int64_t _count(
const client_session* session,
1865 MONGOCXX_PRIVATE std::int64_t _count_documents(
const client_session* session,
1875 MONGOCXX_PRIVATE stdx::optional<result::delete_result> _delete_many(
1880 MONGOCXX_PRIVATE stdx::optional<result::delete_result> _delete_one(
1890 MONGOCXX_PRIVATE
void _drop(
1892 const bsoncxx::stdx::optional<mongocxx::write_concern>&
write_concern);
1898 MONGOCXX_PRIVATE stdx::optional<bsoncxx::document::value> _find_one(
1903 MONGOCXX_PRIVATE stdx::optional<bsoncxx::document::value> _find_one_and_delete(
1908 MONGOCXX_PRIVATE stdx::optional<bsoncxx::document::value> _find_one_and_replace(
1914 MONGOCXX_PRIVATE stdx::optional<bsoncxx::document::value> _find_one_and_update(
1920 MONGOCXX_PRIVATE stdx::optional<result::insert_one> _insert_one(
1925 MONGOCXX_PRIVATE
void _rename(
1928 bool drop_target_before_rename,
1929 const bsoncxx::stdx::optional<class write_concern>&
write_concern);
1931 MONGOCXX_PRIVATE stdx::optional<result::replace_one> _replace_one(
1936 MONGOCXX_PRIVATE stdx::optional<result::replace_one> _replace_one(
1942 MONGOCXX_PRIVATE stdx::optional<result::update> _update_one(
1948 MONGOCXX_PRIVATE stdx::optional<result::update> _update_many(
1959 class bulk_write _init_insert_many(const options::insert& options,
1962 void _insert_many_doc_handler(class bulk_write& writes,
1963 bsoncxx::builder::basic::array& inserted_ids,
1964 bsoncxx::document::view doc) const;
1966 stdx::optional<result::insert_many> _exec_insert_many(
1967 class bulk_write& writes, bsoncxx::builder::basic::array& inserted_ids);
1969 template <typename document_view_iterator_type>
1970 MONGOCXX_PRIVATE stdx::optional<result::insert_many> _insert_many(
1971 const client_session* session,
1972 document_view_iterator_type begin,
1973 document_view_iterator_type end,
1974 const options::insert& options);
1976 class MONGOCXX_PRIVATE impl;
1978 MONGOCXX_PRIVATE impl& _get_impl();
1979 MONGOCXX_PRIVATE const impl& _get_impl() const;
1981 std::unique_ptr<impl> _impl;
1985 const model::write& write, const options::bulk_write& options) {
1991 return create_bulk_write(session, options).
append(write).
execute();
1994 template <
typename container_type>
1995 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::bulk_write(
1997 return bulk_write(requests.begin(), requests.end(), options);
2000 template <
typename container_type>
2001 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::bulk_write(
2003 const container_type& requests,
2005 return bulk_write(session, requests.begin(), requests.end(), options);
2008 template <
typename write_model_iterator_type>
2009 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::bulk_write(
2010 write_model_iterator_type begin,
2011 write_model_iterator_type end,
2013 auto writes = create_bulk_write(options);
2014 std::for_each(begin, end, [&](
const model::write& current) { writes.append(current); });
2015 return writes.execute();
2018 template <
typename write_model_iterator_type>
2019 MONGOCXX_INLINE stdx::optional<result::bulk_write> collection::bulk_write(
2021 write_model_iterator_type begin,
2022 write_model_iterator_type end,
2024 auto writes = create_bulk_write(session, options);
2025 std::for_each(begin, end, [&](
const model::write& current) { writes.append(current); });
2026 return writes.execute();
2029 template <
typename container_type>
2032 return insert_many(container.begin(), container.end(), options);
2035 template <
typename container_type>
2038 const container_type& container,
2040 return insert_many(session, container.begin(), container.end(), options);
2043 template <
typename document_view_iterator_type>
2044 MONGOCXX_INLINE stdx::optional<result::insert_many> collection::_insert_many(
2047 document_view_iterator_type begin,
2048 document_view_iterator_type end,
2051 auto writes = _init_insert_many(options, session);
2053 _insert_many_doc_handler(writes, inserted_ids, doc);
2055 return _exec_insert_many(writes, inserted_ids);
2058 template <
typename document_view_iterator_type>
2060 document_view_iterator_type begin,
2061 document_view_iterator_type end,
2063 return _insert_many(
nullptr, begin, end, options);
2066 template <
typename document_view_iterator_type>
2069 document_view_iterator_type begin,
2070 document_view_iterator_type end,
2072 return _insert_many(&session, begin, end, options);
2075 MONGOCXX_INLINE_NAMESPACE_END
2078 #include <mongocxx/config/postlude.hpp>