Loading...
Searching...
No Matches
collection.hpp
Go to the documentation of this file.
//
// Copyright 2009-present MongoDB, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/v1/collection-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <mongocxx/v1/client_session-fwd.hpp>
#include <mongocxx/v1/cursor-fwd.hpp>
#include <mongocxx/v1/delete_many_result-fwd.hpp>
#include <mongocxx/v1/delete_one_result-fwd.hpp>
#include <mongocxx/v1/insert_one_result-fwd.hpp>
#include <mongocxx/v1/pipeline-fwd.hpp>
#include <mongocxx/v1/read_concern-fwd.hpp>
#include <mongocxx/v1/read_preference-fwd.hpp>
#include <mongocxx/v1/replace_one_result-fwd.hpp>
#include <mongocxx/v1/search_indexes-fwd.hpp>
#include <mongocxx/v1/update_many_result-fwd.hpp>
#include <mongocxx/v1/update_one_result-fwd.hpp>
#include <bsoncxx/v1/detail/type_traits.hpp>
#include <bsoncxx/v1/document/value.hpp>
#include <bsoncxx/v1/document/view.hpp>
#include <bsoncxx/v1/stdx/optional.hpp>
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <bsoncxx/v1/types/value.hpp>
#include <mongocxx/v1/aggregate_options.hpp>
#include <mongocxx/v1/bulk_write.hpp>
#include <mongocxx/v1/change_stream.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <mongocxx/v1/count_options.hpp>
#include <mongocxx/v1/delete_many_options.hpp>
#include <mongocxx/v1/delete_one_options.hpp>
#include <mongocxx/v1/distinct_options.hpp>
#include <mongocxx/v1/estimated_document_count_options.hpp>
#include <mongocxx/v1/find_one_and_delete_options.hpp>
#include <mongocxx/v1/find_one_and_replace_options.hpp>
#include <mongocxx/v1/find_one_and_update_options.hpp>
#include <mongocxx/v1/find_options.hpp>
#include <mongocxx/v1/indexes.hpp>
#include <mongocxx/v1/insert_many_options.hpp>
#include <mongocxx/v1/insert_many_result.hpp>
#include <mongocxx/v1/insert_one_options.hpp>
#include <mongocxx/v1/replace_one_options.hpp>
#include <mongocxx/v1/update_many_options.hpp>
#include <mongocxx/v1/update_one_options.hpp>
#include <mongocxx/v1/write_concern.hpp>
#include <cstdint>
#include <string>
#include <system_error>
#include <type_traits>
#include <utility>
#include <vector>
namespace mongocxx {
namespace v1 {
class collection {
private:
class impl;
void* _impl;
template <typename Container>
using has_begin_expr = decltype((std::declval<Container const&>().begin()));
template <typename Container>
struct has_begin : bsoncxx::detail::is_detected<has_begin_expr, Container> {};
template <typename Container>
using has_end_expr = decltype((std::declval<Container const&>().end()));
template <typename Container>
struct has_end : bsoncxx::detail::is_detected<has_end_expr, Container> {};
static void is_write_iter_expr_impl(v1::bulk_write::single) {}
template <typename InputIt>
using is_write_iter_expr = decltype((is_write_iter_expr_impl)(*std::declval<InputIt&>()));
template <typename InputIt>
struct is_write_iter : bsoncxx::detail::is_detected<is_write_iter_expr, InputIt> {};
template <typename Sentinel, typename InputIt>
struct is_sentinel_for : bsoncxx::detail::is_equality_comparable<Sentinel, InputIt> {};
template <typename Container>
struct is_container : bsoncxx::detail::conjunction<has_begin<Container>, has_end<Container>> {};
static void is_document_iter_expr_impl(bsoncxx::v1::document::view) {}
template <typename InputIt>
using is_document_iter_expr = decltype((is_document_iter_expr_impl)(*std::declval<InputIt&>()));
template <typename InputIt>
struct is_document_iter : bsoncxx::detail::is_detected<is_document_iter_expr, InputIt> {};
public:
MONGOCXX_ABI_EXPORT_CDECL() ~collection();
MONGOCXX_ABI_EXPORT_CDECL() collection(collection&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(collection&) operator=(collection&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() collection(collection const& other);
MONGOCXX_ABI_EXPORT_CDECL(collection&) operator=(collection const& other);
MONGOCXX_ABI_EXPORT_CDECL() collection();
explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) aggregate(
v1::pipeline const& pipeline,
v1::aggregate_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor)
aggregate(v1::client_session const& session, v1::pipeline const& pipeline, v1::aggregate_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::bulk_write) create_bulk_write(v1::bulk_write::options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::bulk_write) create_bulk_write(
v1::client_session const& session,
v1::bulk_write::options const& opts = {});
bsoncxx::v1::stdx::optional<v1::bulk_write::result> write(
v1::bulk_write::single const& write,
v1::bulk_write::options const& opts = {}) {
return this->create_bulk_write(opts).append(write).execute();
}
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 = {}) {
return this->create_bulk_write(session, opts).append(write).execute();
}
template <typename Container, bsoncxx::detail::enable_if_t<is_container<Container>::value>* = nullptr>
bsoncxx::v1::stdx::optional<v1::bulk_write::result> bulk_write(
Container const& writes,
v1::bulk_write::options const& opts = {}) {
return this->bulk_write(writes.begin(), writes.end(), opts);
}
template <typename Container, bsoncxx::detail::enable_if_t<is_container<Container>::value>* = nullptr>
bsoncxx::v1::stdx::optional<v1::bulk_write::result>
bulk_write(v1::client_session const& session, Container const& writes, v1::bulk_write::options const& opts = {}) {
return this->bulk_write(session, writes.begin(), writes.end(), opts);
}
template <
typename InputIt,
typename Sentinel,
bsoncxx::detail::enable_if_t<is_write_iter<InputIt>::value && is_sentinel_for<Sentinel, InputIt>::value>* =
nullptr>
bsoncxx::v1::stdx::optional<v1::bulk_write::result>
bulk_write(InputIt begin, Sentinel end, v1::bulk_write::options const& opts = {}) {
v1::bulk_write bulk{this->create_bulk_write(opts)};
for (auto iter = begin; iter != end; ++iter) {
bulk.append(*iter);
}
return bulk.execute();
}
template <
typename InputIt,
typename Sentinel,
bsoncxx::detail::enable_if_t<is_write_iter<InputIt>::value && is_sentinel_for<Sentinel, InputIt>::value>* =
nullptr>
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 = {}) {
v1::bulk_write bulk{this->create_bulk_write(session, opts)};
for (auto iter = begin; iter != end; ++iter) {
bulk.append(*iter);
}
return bulk.execute();
}
MONGOCXX_ABI_EXPORT_CDECL(std::int64_t) count_documents(
bsoncxx::v1::document::view filter,
v1::count_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(std::int64_t)
count_documents(
v1::client_session const& session,
bsoncxx::v1::document::view filter,
v1::count_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(std::int64_t) estimated_document_count(
v1::estimated_document_count_options const& opts = {});
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 = {}) {
return this->indexes().create_one(std::move(keys), std::move(index_opts), create_opts);
}
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 = {}) {
return this->indexes().create_one(session, std::move(keys), std::move(index_opts), create_opts);
}
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::delete_many_result>) delete_many(
bsoncxx::v1::document::view q,
v1::delete_many_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::delete_one_result>) delete_one(
bsoncxx::v1::document::view q,
v1::delete_one_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::delete_one_result>)
delete_one(
v1::client_session const& session,
bsoncxx::v1::document::view q,
v1::delete_one_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor)
distinct(
bsoncxx::v1::stdx::string_view key,
bsoncxx::v1::document::view query,
v1::distinct_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) distinct(
v1::client_session const& session,
bsoncxx::v1::stdx::string_view key,
bsoncxx::v1::document::view query,
v1::distinct_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(void) drop(
bsoncxx::v1::stdx::optional<v1::write_concern> const& wc = {},
bsoncxx::v1::document::view opts = {});
MONGOCXX_ABI_EXPORT_CDECL(void) drop(
v1::client_session const& session,
bsoncxx::v1::stdx::optional<v1::write_concern> const& wc = {},
bsoncxx::v1::document::view opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) find(bsoncxx::v1::document::view filter, v1::find_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor)
find(v1::client_session const& session, bsoncxx::v1::document::view filter, v1::find_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::value>) find_one(
bsoncxx::v1::document::view filter,
v1::find_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::value>)
find_one(v1::client_session const& session, bsoncxx::v1::document::view filter, v1::find_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::insert_one_result>) insert_one(
bsoncxx::v1::document::view document,
v1::insert_one_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
template <typename Container, bsoncxx::detail::enable_if_t<is_container<Container>::value>* = nullptr>
bsoncxx::v1::stdx::optional<v1::insert_many_result> insert_many(
Container const& docs,
v1::insert_many_options const& opts = {}) {
return this->insert_many(docs.begin(), docs.end(), opts);
}
template <typename Container, bsoncxx::detail::enable_if_t<is_container<Container>::value>* = nullptr>
bsoncxx::v1::stdx::optional<v1::insert_many_result>
insert_many(v1::client_session const& session, Container const& docs, v1::insert_many_options const& opts = {}) {
return this->insert_many(session, docs.begin(), docs.end(), opts);
}
template <
typename InputIt,
typename Sentinel,
bsoncxx::detail::enable_if_t<is_document_iter<InputIt>::value && is_sentinel_for<Sentinel, InputIt>::value>* =
nullptr>
bsoncxx::v1::stdx::optional<v1::insert_many_result>
insert_many(InputIt begin, Sentinel end, v1::insert_many_options const& opts = {}) {
v1::bulk_write bulk{this->_create_insert_many(nullptr, opts)};
std::vector<bsoncxx::v1::types::value> inserted_ids;
for (auto iter = begin; iter != end; ++iter) {
this->_append_insert_many(bulk, inserted_ids, *iter);
}
return this->_execute_insert_many(bulk, inserted_ids);
}
template <
typename InputIt,
typename Sentinel,
bsoncxx::detail::enable_if_t<is_document_iter<InputIt>::value && is_sentinel_for<Sentinel, InputIt>::value>* =
nullptr>
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 = {}) {
v1::bulk_write bulk{this->_create_insert_many(&session, opts)};
std::vector<bsoncxx::v1::types::value> inserted_ids;
for (auto iter = begin; iter != end; ++iter) {
this->_append_insert_many(bulk, inserted_ids, *iter);
}
return this->_execute_insert_many(bulk, inserted_ids);
}
v1::cursor list_indexes() {
return this->indexes().list();
}
v1::cursor list_indexes(v1::client_session const& session) {
return this->indexes().list(session);
}
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::string_view) name() const;
MONGOCXX_ABI_EXPORT_CDECL(void) rename(
bsoncxx::v1::stdx::string_view new_name,
bool drop_target = false,
bsoncxx::v1::stdx::optional<v1::write_concern> const& write_concern = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(void) read_concern(v1::read_concern const& rc);
MONGOCXX_ABI_EXPORT_CDECL(v1::read_concern) read_concern() const;
MONGOCXX_ABI_EXPORT_CDECL(void) read_preference(v1::read_preference const& rp);
MONGOCXX_ABI_EXPORT_CDECL(v1::read_preference) read_preference() const;
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::update_many_result>)
update_many(bsoncxx::v1::document::view filter, v1::pipeline const& update, update_many_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::update_one_result>)
update_one(bsoncxx::v1::document::view filter, v1::pipeline const& update, update_one_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(void) write_concern(v1::write_concern const& wc);
MONGOCXX_ABI_EXPORT_CDECL(v1::write_concern) write_concern() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::indexes) indexes();
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(v1::change_stream::options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(
v1::client_session const& session,
v1::change_stream::options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(
v1::pipeline const& pipeline,
v1::change_stream::options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream)
watch(v1::client_session const& session, v1::pipeline const& pipeline, v1::change_stream::options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::search_indexes) search_indexes();
enum class errc {
zero,
max_time_u32,
};
static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
friend std::error_code make_error_code(errc v) {
return {static_cast<int>(v), error_category()};
}
class internal;
private:
/* explicit(false) */ collection(void* impl);
MONGOCXX_ABI_EXPORT_CDECL(v1::bulk_write) _create_insert_many(
v1::client_session const* session,
v1::insert_many_options const& opts);
static MONGOCXX_ABI_EXPORT_CDECL(void) _append_insert_many(
v1::bulk_write& bulk,
std::vector<bsoncxx::v1::types::value>& inserted_ids,
bsoncxx::v1::document::view doc);
static MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::insert_many_result>) _execute_insert_many(
v1::bulk_write& bulk,
std::vector<bsoncxx::v1::types::value>& inserted_ids);
};
} // namespace v1
} // namespace mongocxx
namespace std {
template <>
struct is_error_code_enum<mongocxx::v1::collection::errc> : true_type {};
} // namespace std
#include <mongocxx/v1/detail/postlude.hpp>
aggregate_options.hpp
Provides mongocxx::v1::aggregate_options.
bsoncxx::v1::document::value
A BSON document.
Definition value.hpp:44
bsoncxx::v1::document::view
A non-owning, read-only BSON document.
Definition view.hpp:52
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
mongocxx::v1::aggregate_options
Options for an "aggregate" command.
Definition aggregate_options.hpp:62
mongocxx::v1::bulk_write::options
Options for a bulk write operation.
Definition bulk_write.hpp:893
mongocxx::v1::bulk_write::single
A single write operation.
Definition bulk_write.hpp:746
mongocxx::v1::bulk_write
A list of bulk write operations.
Definition bulk_write.hpp:53
mongocxx::v1::bulk_write::append
bulk_write & append(single const &op)
Append a single write operation.
mongocxx::v1::bulk_write::execute
bsoncxx::v1::stdx::optional< result > execute()
Execute the appended operations.
mongocxx::v1::change_stream::options
Options for mongocxx::v1::change_stream.
Definition change_stream.hpp:170
mongocxx::v1::change_stream
A MongoDB change stream.
Definition change_stream.hpp:48
mongocxx::v1::client_session
A MongoDB client session.
Definition client_session.hpp:46
mongocxx::v1::collection::read_preference
v1::read_preference read_preference() const
Return the current default "readPreference" to use for operations on this collection.
mongocxx::v1::collection::write
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:207
mongocxx::v1::collection::watch
v1::change_stream watch(v1::client_session const &session, v1::change_stream::options const &opts={})
Return a change stream subscribed to this collection.
mongocxx::v1::collection::errc
errc
Errors codes which may be returned by mongocxx::v1::collection.
Definition collection.hpp:905
mongocxx::v1::collection::errc::max_time_u32
@ max_time_u32
The "maxTimeMS" field must be representable as an std::uint32_t.
Definition collection.hpp:907
mongocxx::v1::collection::errc::zero
@ zero
Zero.
Definition collection.hpp:906
mongocxx::v1::collection::insert_one
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.
mongocxx::v1::collection::drop
void drop(v1::client_session const &session, bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={}, bsoncxx::v1::document::view opts={})
Drop this collection.
mongocxx::v1::collection::write_concern
v1::write_concern write_concern() const
Return the current default "writeConcern" to use for operations on this collection.
mongocxx::v1::collection::find_one_and_update
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.
mongocxx::v1::collection::error_category
static std::error_category const & error_category()
The error category for mongocxx::v1::collection::errc.
mongocxx::v1::collection::insert_many
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:603
mongocxx::v1::collection::count_documents
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.
mongocxx::v1::collection::replace_one
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.
mongocxx::v1::collection::delete_one
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.
mongocxx::v1::collection::watch
v1::change_stream watch(v1::change_stream::options const &opts={})
Return a change stream subscribed to this collection.
mongocxx::v1::collection::bulk_write
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:281
mongocxx::v1::collection::replace_one
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.
mongocxx::v1::collection::name
bsoncxx::v1::stdx::string_view name() const
Return the name of this collection.
mongocxx::v1::collection::rename
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.
mongocxx::v1::collection::read_concern
v1::read_concern read_concern() const
Return the current default "readConcern" to use for operations on this collection.
mongocxx::v1::collection::find_one_and_delete
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.
mongocxx::v1::collection::list_indexes
v1::cursor list_indexes(v1::client_session const &session)
Equivalent to this->indexes.list(session).
Definition collection.hpp:682
mongocxx::v1::collection::distinct
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.
mongocxx::v1::collection::search_indexes
v1::search_indexes search_indexes()
Manage Atlas Search Indexes associated with this collection.
mongocxx::v1::collection::write_concern
void write_concern(v1::write_concern const &wc)
Set the default "writeConcern" to use for operations on this collection.
mongocxx::v1::collection::estimated_document_count
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.
mongocxx::v1::collection::read_concern
void read_concern(v1::read_concern const &rc)
Set the default "readConcern" to use for operations on this collection.
mongocxx::v1::collection::update_one
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.
mongocxx::v1::collection::update_many
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.
mongocxx::v1::collection::find_one_and_delete
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.
mongocxx::v1::collection::collection
collection()
Default initialization.
mongocxx::v1::collection::create_bulk_write
v1::bulk_write create_bulk_write(v1::bulk_write::options const &opts={})
Create a bulk write operation.
mongocxx::v1::collection::find_one_and_update
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.
mongocxx::v1::collection::delete_many
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.
mongocxx::v1::collection::find_one_and_update
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.
mongocxx::v1::collection::insert_many
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:614
mongocxx::v1::collection::insert_many
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:643
mongocxx::v1::collection::watch
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.
mongocxx::v1::collection::insert_one
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.
mongocxx::v1::collection::rename
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.
mongocxx::v1::collection::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition collection.hpp:918
mongocxx::v1::collection::find_one_and_replace
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.
mongocxx::v1::collection::update_one
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.
mongocxx::v1::collection::bulk_write
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:237
mongocxx::v1::collection::read_preference
void read_preference(v1::read_preference const &rp)
Set the default "readPreference" to use for operations on this collection.
mongocxx::v1::collection::delete_many
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.
mongocxx::v1::collection::update_one
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.
mongocxx::v1::collection::insert_many
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:657
mongocxx::v1::collection::create_bulk_write
v1::bulk_write create_bulk_write(v1::client_session const &session, v1::bulk_write::options const &opts={})
Create a bulk write operation.
mongocxx::v1::collection::bulk_write
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:223
mongocxx::v1::collection::find_one
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(...).
mongocxx::v1::collection::create_index
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:344
mongocxx::v1::collection::update_many
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.
mongocxx::v1::collection::~collection
~collection()
Destroy this object.
mongocxx::v1::collection::aggregate
v1::cursor aggregate(v1::pipeline const &pipeline, v1::aggregate_options const &opts={})
Run an aggregation framework pipeline.
mongocxx::v1::collection::find_one_and_replace
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.
mongocxx::v1::collection::collection
collection(collection &&other) noexcept
Move constructor.
mongocxx::v1::collection::create_index
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:334
mongocxx::v1::collection::indexes
v1::indexes indexes()
Manage indexes associated with this collection.
mongocxx::v1::collection::update_many
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.
mongocxx::v1::collection::list_indexes
v1::cursor list_indexes()
Equivalent to this->indexes.list().
Definition collection.hpp:675
mongocxx::v1::collection::write
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:201
mongocxx::v1::collection::find_one_and_update
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.
mongocxx::v1::collection::bulk_write
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:268
mongocxx::v1::collection::drop
void drop(bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={}, bsoncxx::v1::document::view opts={})
Drop this collection.
mongocxx::v1::collection::distinct
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.
mongocxx::v1::collection::find
v1::cursor find(bsoncxx::v1::document::view filter, v1::find_options const &opts={})
Find documents in this collection matching the given query filter.
mongocxx::v1::count_options
Options for a "countDocuments" operation.
Definition count_options.hpp:58
mongocxx::v1::cursor
A MongoDB cursor.
Definition cursor.hpp:39
mongocxx::v1::delete_many_options
Options for a "deleteMany" operation.
Definition delete_many_options.hpp:53
mongocxx::v1::delete_one_options
Options for a "deleteOne" operation.
Definition delete_one_options.hpp:53
mongocxx::v1::distinct_options
Options for a "distinct" command.
Definition distinct_options.hpp:53
mongocxx::v1::estimated_document_count_options
Options for an "estimatedDocumentCount" operation.
Definition estimated_document_count_options.hpp:49
mongocxx::v1::find_one_and_delete_options
Options for a "findOneAndDelete" operation.
Definition find_one_and_delete_options.hpp:59
mongocxx::v1::find_one_and_replace_options
Options for a "findOneAndReplace" operation.
Definition find_one_and_replace_options.hpp:63
mongocxx::v1::find_one_and_update_options
Options for a "findOneAndUpdate" operation.
Definition find_one_and_update_options.hpp:66
mongocxx::v1::find_options
Options for a "find" command.
Definition find_options.hpp:72
mongocxx::v1::indexes::create_one_options
Options for mongocxx::v1::indexes::create_one.
Definition indexes.hpp:429
mongocxx::v1::indexes
Support for MongoDB indexes.
Definition indexes.hpp:56
mongocxx::v1::indexes::create_one
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:929
mongocxx::v1::indexes::list
v1::cursor list(list_options const &list_opts={})
Return all indexes in the associated collection.
mongocxx::v1::insert_many_options
Options for an "insertMany" operation.
Definition insert_many_options.hpp:49
mongocxx::v1::insert_one_options
Options for an "insertOne" operation.
Definition insert_one_options.hpp:48
mongocxx::v1::pipeline
A MongoDB aggregation pipeline.
Definition pipeline.hpp:41
mongocxx::v1::read_concern
Options related to a MongoDB Read Concern.
Definition read_concern.hpp:42
mongocxx::v1::read_preference
Options related to a MongoDB Read Preference.
Definition read_preference.hpp:47
mongocxx::v1::replace_one_options
Options for a "replaceOne" operation.
Definition replace_one_options.hpp:56
mongocxx::v1::search_indexes
Support for MongoDB Atlas Search indexes.
Definition search_indexes.hpp:49
mongocxx::v1::update_many_options
Options for an "updateMany" operation.
Definition update_many_options.hpp:58
mongocxx::v1::update_one_options
Options for an "updateOne" operation.
Definition update_one_options.hpp:59
mongocxx::v1::write_concern
Options related to a MongoDB Write Concern.
Definition write_concern.hpp:47
count_options.hpp
Provides mongocxx::v1::count_options.
delete_many_options.hpp
Provides mongocxx::v1::delete_many_options.
delete_many_result-fwd.hpp
Declares mongocxx::v1::delete_many_result.
delete_one_options.hpp
Provides mongocxx::v1::delete_one_options.
delete_one_result-fwd.hpp
Declares mongocxx::v1::delete_one_result.
distinct_options.hpp
Provides mongocxx::v1::distinct_options.
estimated_document_count_options.hpp
Provides mongocxx::v1::estimated_document_count_options.
find_one_and_delete_options.hpp
Provides mongocxx::v1::find_one_and_delete_options.
find_one_and_replace_options.hpp
Provides mongocxx::v1::find_one_and_replace_options.
find_one_and_update_options.hpp
Provides mongocxx::v1::find_one_and_update_options.
find_options.hpp
Provides mongocxx::v1::find_options.
indexes.hpp
Provides mongocxx::v1::indexes.
insert_many_options.hpp
Provides mongocxx::v1::insert_many_options.
insert_many_result.hpp
Provides mongocxx::v1::insert_many_result.
insert_one_options.hpp
Provides mongocxx::v1::insert_one_options.
insert_one_result-fwd.hpp
Declares mongocxx::v1::insert_one_result.
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::options
Declares entities representing options to use with various commands.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v1::source_errc::mongocxx
@ mongocxx
From the mongocxx library.
Definition exception.hpp:40
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
replace_one_options.hpp
Provides mongocxx::v1::replace_one_options.
replace_one_result-fwd.hpp
Declares mongocxx::v1::replace_one_result.
search_indexes-fwd.hpp
Declares mongocxx::v1::search_indexes.
update_many_options.hpp
Provides mongocxx::v1::update_many_options.
update_many_result-fwd.hpp
Declares mongocxx::v1::update_many_result.
update_one_options.hpp
Provides mongocxx::v1::update_one_options.
update_one_result-fwd.hpp
Declares mongocxx::v1::update_one_result.
bulk_write.hpp
Provides entities related to write operations.
change_stream.hpp
Provides mongocxx::v1::change_stream.
client_session-fwd.hpp
Declares mongocxx::v1::client_session.
collection-fwd.hpp
Declares mongocxx::v1::collection.
cursor-fwd.hpp
Declares mongocxx::v1::cursor.
type_traits.hpp
For internal use only!
value.hpp
Provides bsoncxx::v1::document::value.
view.hpp
Provides bsoncxx::v1::document::view.
pipeline-fwd.hpp
Declares mongocxx::v1::pipeline.
read_concern-fwd.hpp
Declares mongocxx::v1::read_concern.
read_preference-fwd.hpp
Declares mongocxx::v1::read_preference.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
value.hpp
Provides bsoncxx::v1::types::value.
write_concern.hpp
Provides mongocxx::v1::write_concern.