67#include <system_error>
88 template <
typename Container>
89 using has_begin_expr =
decltype((std::declval<Container const&>().begin()));
91 template <
typename Container>
92 struct has_begin : bsoncxx::detail::is_detected<has_begin_expr, Container> {};
94 template <
typename Container>
95 using has_end_expr =
decltype((std::declval<Container const&>().end()));
97 template <
typename Container>
98 struct has_end : bsoncxx::detail::is_detected<has_end_expr, Container> {};
102 template <
typename InputIt>
103 using is_write_iter_expr =
decltype((is_write_iter_expr_impl)(*std::declval<InputIt&>()));
105 template <
typename InputIt>
106 struct is_write_iter : bsoncxx::detail::is_detected<is_write_iter_expr, InputIt> {};
108 template <
typename Sentinel,
typename InputIt>
109 struct is_sentinel_for : bsoncxx::detail::is_equality_comparable<Sentinel, InputIt> {};
111 template <
typename Container>
112 struct is_container : bsoncxx::detail::conjunction<has_begin<Container>, has_end<Container>> {};
116 template <
typename InputIt>
117 using is_document_iter_expr =
decltype((is_document_iter_expr_impl)(*std::declval<InputIt&>()));
119 template <
typename InputIt>
120 struct is_document_iter : bsoncxx::detail::is_detected<is_document_iter_expr, InputIt> {};
224 template <typename Container, bsoncxx::detail::enable_if_t<is_container<Container>::value>* =
nullptr>
226 Container
const& writes,
228 return this->
bulk_write(writes.begin(), writes.end(), opts);
237 template <typename Container, bsoncxx::detail::enable_if_t<is_container<Container>::value>* =
nullptr>
240 return this->
bulk_write(session, writes.begin(), writes.end(), opts);
267 bsoncxx::detail::enable_if_t<is_write_iter<InputIt>::value && is_sentinel_for<Sentinel, InputIt>::value>* =
272 for (
auto iter = begin; iter != end; ++iter) {
281 bsoncxx::detail::enable_if_t<is_write_iter<InputIt>::value && is_sentinel_for<Sentinel, InputIt>::value>* =
289 for (
auto iter = begin; iter != end; ++iter) {
340 return this->
indexes().
create_one(std::move(keys), std::move(index_opts), create_opts);
351 return this->
indexes().
create_one(session, std::move(keys), std::move(index_opts), create_opts);
604 template <typename Container, bsoncxx::detail::enable_if_t<is_container<Container>::value>* =
nullptr>
606 Container
const& docs,
608 return this->
insert_many(docs.begin(), docs.end(), opts);
614 template <typename Container, bsoncxx::detail::enable_if_t<is_container<Container>::value>* =
nullptr>
617 return this->
insert_many(session, docs.begin(), docs.end(), opts);
642 bsoncxx::detail::enable_if_t<is_document_iter<InputIt>::value && is_sentinel_for<Sentinel, InputIt>::value>* =
647 std::vector<bsoncxx::v1::types::value> inserted_ids;
648 for (
auto iter = begin; iter != end; ++iter) {
649 this->_append_insert_many(bulk, inserted_ids, *iter);
651 return this->_execute_insert_many(bulk, inserted_ids);
657 bsoncxx::detail::enable_if_t<is_document_iter<InputIt>::value && is_sentinel_for<Sentinel, InputIt>::value>* =
665 std::vector<bsoncxx::v1::types::value> inserted_ids;
666 for (
auto iter = begin; iter != end; ++iter) {
667 this->_append_insert_many(bulk, inserted_ids, *iter);
669 return this->_execute_insert_many(bulk, inserted_ids);
705 bool drop_target =
false,
711 bool drop_target =
false,
941 std::vector<bsoncxx::v1::types::value>& inserted_ids,
946 std::vector<bsoncxx::v1::types::value>& inserted_ids);
955struct is_error_code_enum<
mongocxx::v1::collection::errc> : true_type {};
Provides mongocxx::v1::aggregate_options.
A BSON document.
Definition value.hpp:46
A non-owning, read-only BSON document.
Definition view.hpp:54
A polyfill for std::optional<T>.
Definition optional.hpp:799
A polyfill for std::string_view.
Definition string_view.hpp:412
Options for an "aggregate" command.
Definition aggregate_options.hpp:64
Options for a bulk write operation.
Definition bulk_write.hpp:910
A single write operation.
Definition bulk_write.hpp:762
A list of bulk write operations.
Definition bulk_write.hpp:55
bulk_write & append(single const &op)
Append a single write operation.
bsoncxx::v1::stdx::optional< result > execute()
Execute the appended operations.
Options for mongocxx::v1::change_stream.
Definition change_stream.hpp:174
A MongoDB change stream.
Definition change_stream.hpp:50
A MongoDB client session.
Definition client_session.hpp:48
v1::read_preference read_preference() const
Return the current default "readPreference" to use for operations on this collection.
bsoncxx::v1::stdx::optional< v1::bulk_write::result > write(v1::client_session const &session, v1::bulk_write::single const &write, v1::bulk_write::options const &opts={})
Equivalent to this->bulk_write(...) with a single write operation.
Definition collection.hpp:209
v1::change_stream watch(v1::client_session const &session, v1::change_stream::options const &opts={})
Return a change stream subscribed to this collection.
errc
Errors codes which may be returned by mongocxx::v1::collection.
Definition collection.hpp:909
@ max_time_u32
The "maxTimeMS" field must be representable as an std::uint32_t.
Definition collection.hpp:911
@ zero
Zero.
Definition collection.hpp:910
bsoncxx::v1::stdx::optional< v1::insert_one_result > insert_one(v1::client_session const &session, bsoncxx::v1::document::view document, v1::insert_one_options const &opts={})
Insert a single document into this collection as a bulk write operation.
void drop(v1::client_session const &session, bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={}, bsoncxx::v1::document::view opts={})
Drop this collection.
v1::write_concern write_concern() const
Return the current default "writeConcern" to use for operations on this collection.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one_and_update(v1::client_session const &session, bsoncxx::v1::document::view query, v1::pipeline const &update, v1::find_one_and_update_options const &opts={})
Find a single document in this collection and update it.
static std::error_category const & error_category()
The error category for mongocxx::v1::collection::errc.
bsoncxx::v1::stdx::optional< v1::insert_many_result > insert_many(Container const &docs, v1::insert_many_options const &opts={})
Equivalent to this->insert_many(docs.begin(), docs.end(), opts).
Definition collection.hpp:605
std::int64_t count_documents(bsoncxx::v1::document::view filter, v1::count_options const &opts={})
Return the number of documents in this collection that match the given query filter.
bsoncxx::v1::stdx::optional< v1::replace_one_result > replace_one(bsoncxx::v1::document::view filter, bsoncxx::v1::document::value replacement, v1::replace_one_options const &opts={})
Replace a single document in this collection as a bulk write operation.
bsoncxx::v1::stdx::optional< v1::delete_one_result > delete_one(bsoncxx::v1::document::view q, v1::delete_one_options const &opts={})
Delete a single document in this collection using the given query filter.
v1::change_stream watch(v1::change_stream::options const &opts={})
Return a change stream subscribed to this collection.
bsoncxx::v1::stdx::optional< v1::bulk_write::result > bulk_write(v1::client_session const &session, InputIt begin, Sentinel end, v1::bulk_write::options const &opts={})
Execute multiple write operations.
Definition collection.hpp:283
bsoncxx::v1::stdx::optional< v1::replace_one_result > replace_one(v1::client_session const &session, bsoncxx::v1::document::view filter, bsoncxx::v1::document::value replacement, v1::replace_one_options const &opts={})
Replace a single document in this collection as a bulk write operation.
bsoncxx::v1::stdx::string_view name() const
Return the name of this collection.
void rename(v1::client_session const &session, bsoncxx::v1::stdx::string_view new_name, bool drop_target=false, bsoncxx::v1::stdx::optional< v1::write_concern > const &write_concern={})
Change the name of this collection.
v1::read_concern read_concern() const
Return the current default "readConcern" to use for operations on this collection.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one_and_delete(v1::client_session const &session, bsoncxx::v1::document::view query, v1::find_one_and_delete_options const &opts={})
Find a single document in this collection and delete it, returning the original document.
v1::cursor list_indexes(v1::client_session const &session)
Equivalent to this->indexes.list(session).
Definition collection.hpp:684
v1::cursor distinct(bsoncxx::v1::stdx::string_view key, bsoncxx::v1::document::view query, v1::distinct_options const &opts={})
Return the distinct values for the specified field within this collection.
v1::search_indexes search_indexes()
Manage Atlas Search Indexes associated with this collection.
void write_concern(v1::write_concern const &wc)
Set the default "writeConcern" to use for operations on this collection.
std::int64_t estimated_document_count(v1::estimated_document_count_options const &opts={})
Return an estimate of the number of documents in this collection using collection metadata.
void read_concern(v1::read_concern const &rc)
Set the default "readConcern" to use for operations on this collection.
bsoncxx::v1::stdx::optional< v1::update_one_result > update_one(v1::client_session const &session, bsoncxx::v1::document::view filter, v1::pipeline const &update, v1::update_one_options const &opts={})
Update a single document in this collection as a bulk write operation.
bsoncxx::v1::stdx::optional< v1::update_many_result > update_many(v1::client_session const &session, bsoncxx::v1::document::view filter, v1::pipeline const &update, v1::update_many_options const &opts={})
Update multiple documents in this collection as a bulk write operation.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one_and_delete(bsoncxx::v1::document::view query, v1::find_one_and_delete_options const &opts={})
Find a single document in this collection and delete it, returning the original document.
collection()
Default initialization.
v1::bulk_write create_bulk_write(v1::bulk_write::options const &opts={})
Create a bulk write operation.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one_and_update(bsoncxx::v1::document::view query, bsoncxx::v1::document::view update, v1::find_one_and_update_options const &opts={})
Find a single document in this collection and update it.
bsoncxx::v1::stdx::optional< v1::delete_many_result > delete_many(bsoncxx::v1::document::view q, v1::delete_many_options const &opts={})
Delete multiple documents in this collection using the given query filter.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one_and_update(v1::client_session const &session, bsoncxx::v1::document::view query, bsoncxx::v1::document::view update, v1::find_one_and_update_options const &opts={})
Find a single document in this collection and update it.
bsoncxx::v1::stdx::optional< v1::insert_many_result > insert_many(v1::client_session const &session, Container const &docs, v1::insert_many_options const &opts={})
Equivalent to this->insert_many(session, docs.begin(), docs.end(), opts).
Definition collection.hpp:616
bsoncxx::v1::stdx::optional< v1::insert_many_result > insert_many(InputIt begin, Sentinel end, v1::insert_many_options const &opts={})
Insert the given documents into this collection as a bulk write operation.
Definition collection.hpp:645
v1::change_stream watch(v1::pipeline const &pipeline, v1::change_stream::options const &opts={})
Return a change stream subscribed to this collection with events filtered/modified by pipeline.
bsoncxx::v1::stdx::optional< v1::insert_one_result > insert_one(bsoncxx::v1::document::view document, v1::insert_one_options const &opts={})
Insert a single document into this collection as a bulk write operation.
void rename(bsoncxx::v1::stdx::string_view new_name, bool drop_target=false, bsoncxx::v1::stdx::optional< v1::write_concern > const &write_concern={})
Change the name of this collection.
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition collection.hpp:926
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one_and_replace(bsoncxx::v1::document::view query, bsoncxx::v1::document::view replacement, v1::find_one_and_replace_options const &opts={})
Find a single document in this collection and replace it.
bsoncxx::v1::stdx::optional< v1::update_one_result > update_one(v1::client_session const &session, bsoncxx::v1::document::view filter, bsoncxx::v1::document::view update, v1::update_one_options const &opts={})
Update a single document in this collection as a bulk write operation.
bsoncxx::v1::stdx::optional< v1::bulk_write::result > bulk_write(v1::client_session const &session, Container const &writes, v1::bulk_write::options const &opts={})
Equivalent to this->bulk_write(session, writes.begin(), writes.begin(), opts).
Definition collection.hpp:239
void read_preference(v1::read_preference const &rp)
Set the default "readPreference" to use for operations on this collection.
bsoncxx::v1::stdx::optional< v1::delete_many_result > delete_many(v1::client_session const &session, bsoncxx::v1::document::view q, v1::delete_many_options const &opts={})
Delete multiple documents in this collection using the given query filter.
bsoncxx::v1::stdx::optional< v1::update_one_result > update_one(bsoncxx::v1::document::view filter, bsoncxx::v1::document::view update, v1::update_one_options const &opts={})
Update a single document in this collection as a bulk write operation.
bsoncxx::v1::stdx::optional< v1::insert_many_result > insert_many(v1::client_session const &session, InputIt begin, Sentinel end, v1::insert_many_options const &opts={})
Insert the given documents into this collection as a bulk write operation.
Definition collection.hpp:659
v1::bulk_write create_bulk_write(v1::client_session const &session, v1::bulk_write::options const &opts={})
Create a bulk write operation.
bsoncxx::v1::stdx::optional< v1::bulk_write::result > bulk_write(Container const &writes, v1::bulk_write::options const &opts={})
Equivalent to this->bulk_write(writes.begin(), writes.begin(), opts).
Definition collection.hpp:225
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one(bsoncxx::v1::document::view filter, v1::find_options const &opts={})
Return the first matching document obtained by this->find(...).
bsoncxx::v1::stdx::optional< std::string > create_index(v1::client_session const &session, bsoncxx::v1::document::value keys, bsoncxx::v1::document::value index_opts={}, v1::indexes::create_one_options const &create_opts={})
Equivalent to this->indexes().create_one(session, keys, index_opts, create_opts).
Definition collection.hpp:346
bsoncxx::v1::stdx::optional< v1::update_many_result > update_many(bsoncxx::v1::document::view filter, bsoncxx::v1::document::view update, v1::update_many_options const &opts={})
Update multiple documents in this collection as a bulk write operation.
~collection()
Destroy this object.
v1::cursor aggregate(v1::pipeline const &pipeline, v1::aggregate_options const &opts={})
Run an aggregation framework pipeline.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one_and_replace(v1::client_session const &session, bsoncxx::v1::document::view query, bsoncxx::v1::document::view replacement, v1::find_one_and_replace_options const &opts={})
Find a single document in this collection and replace it.
collection(collection &&other) noexcept
Move constructor.
bsoncxx::v1::stdx::optional< std::string > create_index(bsoncxx::v1::document::value keys, bsoncxx::v1::document::value index_opts={}, v1::indexes::create_one_options const &create_opts={})
Equivalent to this->indexes().create_one(keys, index_opts, create_opts).
Definition collection.hpp:336
v1::indexes indexes()
Manage indexes associated with this collection.
bsoncxx::v1::stdx::optional< v1::update_many_result > update_many(v1::client_session const &session, bsoncxx::v1::document::view filter, bsoncxx::v1::document::view update, v1::update_many_options const &opts={})
Update multiple documents in this collection as a bulk write operation.
v1::cursor list_indexes()
Equivalent to this->indexes.list().
Definition collection.hpp:677
bsoncxx::v1::stdx::optional< v1::bulk_write::result > write(v1::bulk_write::single const &write, v1::bulk_write::options const &opts={})
Equivalent to this->bulk_write(...) with a single write operation.
Definition collection.hpp:203
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::value > find_one_and_update(bsoncxx::v1::document::view query, v1::pipeline const &update, v1::find_one_and_update_options const &opts={})
Find a single document in this collection and update it.
bsoncxx::v1::stdx::optional< v1::bulk_write::result > bulk_write(InputIt begin, Sentinel end, v1::bulk_write::options const &opts={})
Execute multiple write operations.
Definition collection.hpp:270
void drop(bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={}, bsoncxx::v1::document::view opts={})
Drop this collection.
v1::cursor distinct(v1::client_session const &session, bsoncxx::v1::stdx::string_view key, bsoncxx::v1::document::view query, v1::distinct_options const &opts={})
Return the distinct values for the specified field within this collection.
v1::cursor find(bsoncxx::v1::document::view filter, v1::find_options const &opts={})
Find documents in this collection matching the given query filter.
Options for a "countDocuments" operation.
Definition count_options.hpp:58
A MongoDB cursor.
Definition cursor.hpp:41
Options for a "deleteMany" operation.
Definition delete_many_options.hpp:53
Options for a "deleteOne" operation.
Definition delete_one_options.hpp:53
Options for a "distinct" command.
Definition distinct_options.hpp:51
Options for an "estimatedDocumentCount" operation.
Definition estimated_document_count_options.hpp:49
Options for a "findOneAndDelete" operation.
Definition find_one_and_delete_options.hpp:59
Options for a "findOneAndReplace" operation.
Definition find_one_and_replace_options.hpp:63
Options for a "findOneAndUpdate" operation.
Definition find_one_and_update_options.hpp:66
Options for a "find" command.
Definition find_options.hpp:72
Options for mongocxx::v1::indexes::create_one.
Definition indexes.hpp:435
Support for MongoDB indexes.
Definition indexes.hpp:58
bsoncxx::v1::stdx::optional< std::string > create_one(bsoncxx::v1::document::value keys, bsoncxx::v1::document::value index_opts={}, create_one_options const &create_opts={})
Equivalent to this->create_one(model(keys, index_opts), create_opts).
Definition indexes.hpp:935
v1::cursor list(list_options const &list_opts={})
Return all indexes in the associated collection.
Options for an "insertMany" operation.
Definition insert_many_options.hpp:49
Options for an "insertOne" operation.
Definition insert_one_options.hpp:48
A MongoDB aggregation pipeline.
Definition pipeline.hpp:43
Options related to a MongoDB Read Concern.
Definition read_concern.hpp:44
Options related to a MongoDB Read Preference.
Definition read_preference.hpp:49
Options for a "replaceOne" operation.
Definition replace_one_options.hpp:56
Support for MongoDB Atlas Search indexes.
Definition search_indexes.hpp:51
Options for an "updateMany" operation.
Definition update_many_options.hpp:58
Options for an "updateOne" operation.
Definition update_one_options.hpp:59
Options related to a MongoDB Write Concern.
Definition write_concern.hpp:49
Provides mongocxx::v1::count_options.
Provides mongocxx::v1::delete_many_options.
Declares mongocxx::v1::delete_many_result.
Provides mongocxx::v1::delete_one_options.
Declares mongocxx::v1::delete_one_result.
Provides mongocxx::v1::distinct_options.
Provides mongocxx::v1::estimated_document_count_options.
Provides mongocxx::v1::find_one_and_delete_options.
Provides mongocxx::v1::find_one_and_replace_options.
Provides mongocxx::v1::find_one_and_update_options.
Provides mongocxx::v1::find_options.
Provides mongocxx::v1::indexes.
Provides mongocxx::v1::insert_many_options.
Provides mongocxx::v1::insert_many_result.
Provides mongocxx::v1::insert_one_options.
Declares mongocxx::v1::insert_one_result.
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is guaranteed for documented symbols.
@ mongocxx
From the mongocxx library.
Definition exception.hpp:42
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v1::replace_one_options.
Declares mongocxx::v1::replace_one_result.
Declares mongocxx::v1::search_indexes.
Provides mongocxx::v1::update_many_options.
Declares mongocxx::v1::update_many_result.
Provides mongocxx::v1::update_one_options.
Declares mongocxx::v1::update_one_result.
Provides entities related to write operations.
Provides mongocxx::v1::change_stream.
Declares mongocxx::v1::client_session.
Declares mongocxx::v1::collection.
Declares mongocxx::v1::cursor.
Provides bsoncxx::v1::document::value.
Provides bsoncxx::v1::document::view.
Declares mongocxx::v1::pipeline.
Declares mongocxx::v1::read_concern.
Declares mongocxx::v1::read_preference.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Provides bsoncxx::v1::types::value.
Declares mongocxx::v1::write_concern.