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/collection-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/collection.hpp> // IWYU pragma: export
#include <algorithm>
#include <cstdint>
#include <initializer_list>
#include <string> // IWYU pragma: keep: backward compatibility, to be removed.
#include <utility>
#include <mongocxx/bulk_write-fwd.hpp>
#include <mongocxx/client_encryption-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/database-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/builder/basic/array.hpp>
#include <bsoncxx/builder/basic/document.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/builder/basic/kvp.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/builder/concatenate.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/document/view_or_value.hpp>
#include <bsoncxx/oid.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/stdx/string_view.hpp>
#include <bsoncxx/string/view_or_value.hpp>
#include <mongocxx/bulk_write.hpp>
#include <mongocxx/change_stream.hpp>
#include <mongocxx/client_session.hpp>
#include <mongocxx/cursor.hpp>
#include <mongocxx/index_view.hpp>
#include <mongocxx/model/insert_one.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/model/write.hpp>
#include <mongocxx/options/aggregate.hpp>
#include <mongocxx/options/bulk_write.hpp>
#include <mongocxx/options/change_stream.hpp>
#include <mongocxx/options/count.hpp>
#include <mongocxx/options/delete.hpp>
#include <mongocxx/options/distinct.hpp>
#include <mongocxx/options/estimated_document_count.hpp>
#include <mongocxx/options/find.hpp>
#include <mongocxx/options/find_one_and_delete.hpp>
#include <mongocxx/options/find_one_and_replace.hpp>
#include <mongocxx/options/find_one_and_update.hpp>
#include <mongocxx/options/index.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/options/index_view.hpp>
#include <mongocxx/options/insert.hpp>
#include <mongocxx/options/replace.hpp>
#include <mongocxx/options/update.hpp>
#include <mongocxx/pipeline.hpp>
#include <mongocxx/read_concern.hpp>
#include <mongocxx/read_preference.hpp>
#include <mongocxx/result/bulk_write.hpp>
#include <mongocxx/result/delete.hpp>
#include <mongocxx/result/insert_many.hpp>
#include <mongocxx/result/insert_one.hpp>
#include <mongocxx/result/replace_one.hpp>
#include <mongocxx/result/update.hpp>
#include <mongocxx/search_index_view.hpp>
#include <mongocxx/write_concern.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
class collection {
private:
v1::collection _coll;
//
// Utility class supporting the convenience of {} meaning an empty bsoncxx::v_noabi::document.
//
// Users may not use this class directly.
//
// In places where driver methods take this class as a parameter, passing {} will
// translate to a default-constructed bsoncxx::v_noabi::document::view_or_value,
// regardless of other overloads taking other default-constructible types
// for that parameter. This class avoids compiler ambiguity with such overloads.
//
// See collection::update_one for an example of such overloads.
//
class _empty_doc_tag {};
public:
collection() noexcept {}
collection(collection&& other) noexcept = default;
collection& operator=(collection&& other) noexcept = default;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() collection(collection const& other);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(collection&) operator=(collection const& other);
~collection() = default;
/* explicit(false) */ collection(v1::collection collection) : _coll{std::move(collection)} {}
explicit operator v1::collection() && {
return std::move(_coll);
}
explicit operator v1::collection() const& {
return _coll;
}
explicit MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() operator bool() const noexcept;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
aggregate(v_noabi::pipeline const& pipeline, v_noabi::options::aggregate const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
aggregate(
v_noabi::client_session const& session,
v_noabi::pipeline const& pipeline,
v_noabi::options::aggregate const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::bulk_write)
create_bulk_write(v_noabi::options::bulk_write const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::bulk_write)
create_bulk_write(v_noabi::client_session const& session, v_noabi::options::bulk_write const& options = {});
bsoncxx::v_noabi::stdx::optional<v_noabi::result::bulk_write> write(
v_noabi::model::write const& write,
v_noabi::options::bulk_write const& options = {}) {
return this->create_bulk_write(options).append(write).execute();
}
bsoncxx::v_noabi::stdx::optional<v_noabi::result::bulk_write> write(
v_noabi::client_session const& session,
v_noabi::model::write const& write,
v_noabi::options::bulk_write const& options = {}) {
return this->create_bulk_write(session, options).append(write).execute();
}
template <typename container_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::bulk_write> bulk_write(
container_type const& writes,
v_noabi::options::bulk_write const& options = {}) {
return this->bulk_write(writes.begin(), writes.end(), options);
}
template <typename container_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::bulk_write> bulk_write(
v_noabi::client_session const& session,
container_type const& writes,
v_noabi::options::bulk_write const& options = {}) {
return this->bulk_write(session, writes.begin(), writes.end(), options);
}
template <typename write_model_iterator_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::bulk_write> bulk_write(
write_model_iterator_type begin,
write_model_iterator_type end,
v_noabi::options::bulk_write const& options = {}) {
auto writes = create_bulk_write(options);
std::for_each(begin, end, [&](model::write const& current) { writes.append(current); });
return writes.execute();
}
template <typename write_model_iterator_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::bulk_write> bulk_write(
v_noabi::client_session const& session,
write_model_iterator_type begin,
write_model_iterator_type end,
v_noabi::options::bulk_write const& options = {}) {
auto writes = create_bulk_write(session, options);
std::for_each(begin, end, [&](model::write const& current) { writes.append(current); });
return writes.execute();
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::int64_t)
count_documents(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::count const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::int64_t)
count_documents(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::count const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::int64_t)
estimated_document_count(v_noabi::options::estimated_document_count const& options = {});
bsoncxx::v_noabi::document::value create_index(
bsoncxx::v_noabi::document::view_or_value keys,
bsoncxx::v_noabi::document::view_or_value index_options = {},
v_noabi::options::index_view operation_options = {}) {
using namespace bsoncxx::v_noabi::builder::basic;
auto const name_opt = this->indexes().create_one(keys, index_options, operation_options);
return name_opt ? make_document(kvp("name", *name_opt)) : make_document();
}
bsoncxx::v_noabi::document::value create_index(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value keys,
bsoncxx::v_noabi::document::view_or_value index_options = {},
v_noabi::options::index_view operation_options = {}) {
using namespace bsoncxx::v_noabi::builder::basic;
auto const name_opt = this->indexes().create_one(session, keys, index_options, operation_options);
return name_opt ? make_document(kvp("name", *name_opt)) : make_document();
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::delete_result>)
delete_many(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::delete_options const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::delete_result>)
delete_many(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::delete_options const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::delete_result>)
delete_one(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::delete_options const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::delete_result>)
delete_one(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::delete_options const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
distinct(
bsoncxx::v_noabi::string::view_or_value name,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::distinct const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
distinct(
v_noabi::client_session const& session,
bsoncxx::v_noabi::string::view_or_value name,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::distinct const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop(
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern = {},
bsoncxx::v_noabi::document::view_or_value collection_options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop(
v_noabi::client_session const& session,
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern = {},
bsoncxx::v_noabi::document::view_or_value collection_options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
find(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
find(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::find const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::find const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_delete(
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::find_one_and_delete const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_delete(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::find_one_and_delete const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_replace(
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value replacement,
v_noabi::options::find_one_and_replace const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_replace(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value replacement,
v_noabi::options::find_one_and_replace const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_update(
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value update,
v_noabi::options::find_one_and_update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_update(
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::pipeline const& update,
v_noabi::options::find_one_and_update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_update(
bsoncxx::v_noabi::document::view_or_value filter,
std::initializer_list<_empty_doc_tag> update,
v_noabi::options::find_one_and_update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_update(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value update,
v_noabi::options::find_one_and_update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_update(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::pipeline const& update,
v_noabi::options::find_one_and_update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::value>)
find_one_and_update(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
std::initializer_list<_empty_doc_tag> update,
v_noabi::options::find_one_and_update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::insert_one>)
insert_one(bsoncxx::v_noabi::document::view_or_value document, v_noabi::options::insert const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::insert_one>)
insert_one(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value document,
v_noabi::options::insert const& options = {});
template <typename container_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::insert_many> insert_many(
container_type const& container,
v_noabi::options::insert const& options = {}) {
return this->insert_many(container.begin(), container.end(), options);
}
template <typename container_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::insert_many> insert_many(
v_noabi::client_session const& session,
container_type const& container,
v_noabi::options::insert const& options = {}) {
return this->insert_many(session, container.begin(), container.end(), options);
}
template <typename document_view_iterator_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::insert_many> insert_many(
document_view_iterator_type begin,
document_view_iterator_type end,
v_noabi::options::insert const& options = {}) {
return this->_insert_many(nullptr, begin, end, options);
}
template <typename document_view_iterator_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::insert_many> insert_many(
v_noabi::client_session const& session,
document_view_iterator_type begin,
document_view_iterator_type end,
v_noabi::options::insert const& options = {}) {
return this->_insert_many(&session, begin, end, options);
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor) list_indexes() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor) list_indexes(v_noabi::client_session const& session) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::string_view) name() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
rename(
bsoncxx::v_noabi::string::view_or_value new_name,
bool drop_target_before_rename = false,
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
rename(
v_noabi::client_session const& session,
bsoncxx::v_noabi::string::view_or_value new_name,
bool drop_target_before_rename = false,
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) read_concern(v_noabi::read_concern rc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::read_concern) read_concern() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) read_preference(v_noabi::read_preference rp);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::read_preference) read_preference() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::replace_one>)
replace_one(
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value replacement,
v_noabi::options::replace const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::replace_one>)
replace_one(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value replacement,
v_noabi::options::replace const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_many(
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_many(
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::pipeline const& update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_many(
bsoncxx::v_noabi::document::view_or_value filter,
std::initializer_list<_empty_doc_tag> update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_many(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_many(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::pipeline const& update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_many(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
std::initializer_list<_empty_doc_tag> update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_one(
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_one(
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::pipeline const& update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_one(
bsoncxx::v_noabi::document::view_or_value filter,
std::initializer_list<_empty_doc_tag> update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_one(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
bsoncxx::v_noabi::document::view_or_value update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_one(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::pipeline const& update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::update>)
update_one(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
std::initializer_list<_empty_doc_tag> update,
v_noabi::options::update const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) write_concern(v_noabi::write_concern wc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::write_concern) write_concern() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::index_view) indexes();
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream) watch(
v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(v_noabi::client_session const& session, v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(v_noabi::pipeline const& pipe, v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(
v_noabi::client_session const& session,
v_noabi::pipeline const& pipe,
v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::search_index_view) search_indexes();
class internal;
private:
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::bulk_write)
_init_insert_many(v_noabi::options::insert const& options, v_noabi::client_session const* session);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
_insert_many_doc_handler(
v_noabi::bulk_write& writes,
bsoncxx::v_noabi::builder::basic::array& inserted_ids,
bsoncxx::v_noabi::document::view doc) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::result::insert_many>)
_exec_insert_many(v_noabi::bulk_write& writes, bsoncxx::v_noabi::builder::basic::array& inserted_ids);
template <typename document_view_iterator_type>
bsoncxx::v_noabi::stdx::optional<v_noabi::result::insert_many> _insert_many(
v_noabi::client_session const* session,
document_view_iterator_type begin,
document_view_iterator_type end,
v_noabi::options::insert const& options) {
bsoncxx::v_noabi::builder::basic::array inserted_ids;
auto writes = _init_insert_many(options, session);
std::for_each(begin, end, [&inserted_ids, &writes, this](bsoncxx::v_noabi::document::view doc) {
_insert_many_doc_handler(writes, inserted_ids, doc);
});
return _exec_insert_many(writes, inserted_ids);
}
};
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::collection from_v1(v1::collection v) {
return {std::move(v)};
}
inline v1::collection to_v1(v_noabi::collection v) {
return v1::collection{std::move(v)};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
aggregate.hpp
Provides mongocxx::v_noabi::options::aggregate.
array.hpp
Provides bsoncxx::v_noabi::builder::basic::array.
document.hpp
Provides bsoncxx::v_noabi::builder::basic::document.
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
bsoncxx::v_noabi::builder::basic::array
A traditional builder-style interface for constructing a BSON array.
Definition array.hpp:37
bsoncxx::v_noabi::builder::basic::document
A traditional builder-style interface for constructing a BSON document.
Definition document.hpp:41
bsoncxx::v_noabi::document::value
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:48
bsoncxx::v_noabi::document::view
A read-only, non-owning view of a BSON document.
Definition view.hpp:40
bsoncxx::v_noabi::view_or_value
A view-or-value variant type.
Definition view_or_value.hpp:32
mongocxx::collection::collection
collection() noexcept
Default constructs a collection object. The collection is equivalent to the state of a moved from col...
Definition collection.hpp:123
mongocxx::v1::collection
A MongoDB collection.
Definition collection.hpp:81
mongocxx::v_noabi::bulk_write
A batch of write operations that can be sent to the server as a group.
Definition bulk_write.hpp:54
mongocxx::v_noabi::bulk_write::execute
bsoncxx::v_noabi::stdx::optional< result::bulk_write > execute() const
Executes a bulk write.
mongocxx::v_noabi::bulk_write::append
bulk_write & append(v_noabi::model::write const &operation)
Appends a single write to the bulk write operation. The write operation's contents are copied into th...
mongocxx::v_noabi::change_stream
A MongoDB change stream.
Definition change_stream.hpp:44
mongocxx::v_noabi::client_session
Supports MongoDB client session operations.
Definition client_session.hpp:58
mongocxx::v_noabi::collection
A MongoDB collection.
Definition collection.hpp:98
mongocxx::v_noabi::collection::bulk_write
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > bulk_write(write_model_iterator_type begin, write_model_iterator_type end, v_noabi::options::bulk_write const &options={})
Sends writes starting at begin and ending at end to the server as a bulk write operation.
Definition collection.hpp:401
mongocxx::v_noabi::collection::insert_many
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > insert_many(v_noabi::client_session const &session, container_type const &container, v_noabi::options::insert const &options={})
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1220
mongocxx::v_noabi::collection::read_concern
void read_concern(v_noabi::read_concern rc)
Sets the read_concern for this collection. Changes will not have any effect on existing cursors or ot...
mongocxx::v_noabi::collection::bulk_write
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > bulk_write(v_noabi::client_session const &session, write_model_iterator_type begin, write_model_iterator_type end, v_noabi::options::bulk_write const &options={})
Sends writes starting at begin and ending at end to the server as a bulk write operation.
Definition collection.hpp:436
mongocxx::v_noabi::collection::replace_one
bsoncxx::v_noabi::stdx::optional< v_noabi::result::replace_one > replace_one(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement, v_noabi::options::replace const &options={})
Replaces a single document matching the provided filter in this collection.
mongocxx::v_noabi::collection::write_concern
void write_concern(v_noabi::write_concern wc)
Sets the write_concern for this collection. Changes will not have any effect on existing write operat...
mongocxx::v_noabi::collection::create_index
bsoncxx::v_noabi::document::value create_index(bsoncxx::v_noabi::document::view_or_value keys, bsoncxx::v_noabi::document::view_or_value index_options={}, v_noabi::options::index_view operation_options={})
Creates an index over the collection for the provided keys with the provided options.
Definition collection.hpp:538
mongocxx::v_noabi::collection::list_indexes
v_noabi::cursor list_indexes() const
Returns a list of the indexes currently on this collection.
mongocxx::v_noabi::collection::create_index
bsoncxx::v_noabi::document::value create_index(v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value keys, bsoncxx::v_noabi::document::view_or_value index_options={}, v_noabi::options::index_view operation_options={})
Creates an index over the collection for the provided keys with the provided options.
Definition collection.hpp:570
mongocxx::v_noabi::collection::drop
void drop(bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const &write_concern={}, bsoncxx::v_noabi::document::view_or_value collection_options={})
Drops this collection and all its contained documents from the database.
mongocxx::v_noabi::collection::find
v_noabi::cursor find(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const &options={})
Finds the documents in this collection which match the provided filter.
mongocxx::v_noabi::collection::search_indexes
v_noabi::search_index_view search_indexes()
Gets a search_index_view to the collection.
mongocxx::v_noabi::collection::bulk_write
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > bulk_write(container_type const &writes, v_noabi::options::bulk_write const &options={})
Sends a container of writes to the server as a bulk write operation.
Definition collection.hpp:339
mongocxx::v_noabi::collection::update_one
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > update_one(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::update const &options={})
Updates a single document matching the provided filter in this collection.
mongocxx::v_noabi::collection::list_indexes
v_noabi::cursor list_indexes(v_noabi::client_session const &session) const
Returns a list of the indexes currently on this collection.
mongocxx::v_noabi::collection::indexes
v_noabi::index_view indexes()
Gets an index_view to the collection.
mongocxx::v_noabi::collection::name
bsoncxx::v_noabi::stdx::string_view name() const
Returns the name of this collection.
mongocxx::v_noabi::collection::estimated_document_count
std::int64_t estimated_document_count(v_noabi::options::estimated_document_count const &options={})
Returns an estimate of the number of documents in the collection.
mongocxx::v_noabi::collection::aggregate
v_noabi::cursor aggregate(v_noabi::pipeline const &pipeline, v_noabi::options::aggregate const &options={})
Runs an aggregation framework pipeline against this collection.
mongocxx::v_noabi::collection::watch
v_noabi::change_stream watch(v_noabi::options::change_stream const &options={})
Gets a change stream on this collection with an empty pipeline. Change streams are only supported wit...
mongocxx::v_noabi::collection::delete_many
bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > delete_many(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::delete_options const &options={})
Deletes all matching documents from the collection.
mongocxx::v_noabi::collection::write
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > write(v_noabi::client_session const &session, v_noabi::model::write const &write, v_noabi::options::bulk_write const &options={})
Sends a write to the server as a bulk write operation.
Definition collection.hpp:309
mongocxx::v_noabi::collection::insert_one
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_one > insert_one(bsoncxx::v_noabi::document::view_or_value document, v_noabi::options::insert const &options={})
Inserts a single document into the collection. If the document is missing an identifier (_id field) o...
mongocxx::v_noabi::collection::insert_many
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > insert_many(container_type const &container, v_noabi::options::insert const &options={})
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1192
mongocxx::v_noabi::collection::delete_one
bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > delete_one(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::delete_options const &options={})
Deletes a single matching document from the collection.
mongocxx::v_noabi::collection::find_one
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const &options={})
Finds a single document in this collection that match the provided filter.
mongocxx::v_noabi::collection::insert_many
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > insert_many(document_view_iterator_type begin, document_view_iterator_type end, v_noabi::options::insert const &options={})
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1251
mongocxx::v_noabi::collection::read_preference
v_noabi::read_preference read_preference() const
Gets the read_preference for the collection.
mongocxx::v_noabi::collection::create_bulk_write
v_noabi::bulk_write create_bulk_write(v_noabi::options::bulk_write const &options={})
Creates a new bulk operation to be executed against this collection. The lifetime of the bulk_write i...
mongocxx::v_noabi::collection::count_documents
std::int64_t count_documents(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::count const &options={})
Counts the number of documents matching the provided filter.
mongocxx::v_noabi::collection::distinct
v_noabi::cursor distinct(bsoncxx::v_noabi::string::view_or_value name, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::distinct const &options={})
Finds the distinct values for a specified field across the collection.
mongocxx::v_noabi::collection::insert_many
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > insert_many(v_noabi::client_session const &session, document_view_iterator_type begin, document_view_iterator_type end, v_noabi::options::insert const &options={})
Inserts multiple documents into the collection. If any of the documents are missing identifiers the d...
Definition collection.hpp:1280
mongocxx::v_noabi::collection::read_concern
v_noabi::read_concern read_concern() const
Gets the read_concern for the collection.
mongocxx::v_noabi::collection::rename
void rename(bsoncxx::v_noabi::string::view_or_value new_name, bool drop_target_before_rename=false, bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const &write_concern={})
Rename this collection.
mongocxx::v_noabi::collection::collection
collection() noexcept
Default constructs a collection object. The collection is equivalent to the state of a moved from col...
Definition collection.hpp:123
mongocxx::v_noabi::collection::collection
collection(collection &&other) noexcept=default
Move constructs a collection.
mongocxx::v_noabi::collection::read_preference
void read_preference(v_noabi::read_preference rp)
Sets the read_preference for this collection. Changes will not have any effect on existing cursors or...
mongocxx::v_noabi::collection::find_one_and_delete
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one_and_delete(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find_one_and_delete const &options={})
Finds a single document matching the filter, deletes it, and returns the original.
mongocxx::v_noabi::collection::update_many
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > update_many(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::update const &options={})
Updates multiple documents matching the provided filter in this collection.
mongocxx::v_noabi::collection::find_one_and_replace
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one_and_replace(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement, v_noabi::options::find_one_and_replace const &options={})
Finds a single document matching the filter, replaces it, and returns either the original or the repl...
mongocxx::v_noabi::collection::bulk_write
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > bulk_write(v_noabi::client_session const &session, container_type const &writes, v_noabi::options::bulk_write const &options={})
Sends a container of writes to the server as a bulk write operation.
Definition collection.hpp:370
mongocxx::v_noabi::collection::write_concern
v_noabi::write_concern write_concern() const
Gets the write_concern for the collection.
mongocxx::v_noabi::collection::write
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > write(v_noabi::model::write const &write, v_noabi::options::bulk_write const &options={})
Sends a write to the server as a bulk write operation.
Definition collection.hpp:280
mongocxx::v_noabi::collection::operator=
collection & operator=(collection &&other) noexcept=default
Move assigns a collection.
mongocxx::v_noabi::collection::find_one_and_update
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > find_one_and_update(bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::find_one_and_update const &options={})
Finds a single document matching the filter, updates it, and returns either the original or the newly...
mongocxx::v_noabi::cursor
A cursor over the documents returned by a query to a MongoDB server.
Definition cursor.hpp:50
mongocxx::v_noabi::index_view
A MongoDB index.
Definition index_view.hpp:50
mongocxx::v_noabi::index_view::create_one
bsoncxx::v_noabi::stdx::optional< std::string > create_one(bsoncxx::v_noabi::document::view_or_value const &keys, bsoncxx::v_noabi::document::view_or_value const &index_options={}, v_noabi::options::index_view const &options={})
Creates an index. A convenience method that calls create_many.
Definition index_view.hpp:122
mongocxx::v_noabi::model::write
A single write operation for use with mongocxx::v_noabi::bulk_write.
Definition write.hpp:45
mongocxx::v_noabi::options::bulk_write
Used by mongocxx::v_noabi::collection.
Definition bulk_write.hpp:46
mongocxx::v_noabi::options::change_stream
Used by change streams.
Definition change_stream.hpp:52
mongocxx::v_noabi::options::index_view
Used by MongoDB index view operations.
Definition index_view.hpp:45
mongocxx::v_noabi::options::insert
Used by mongocxx::v_noabi::collection.
Definition insert.hpp:45
mongocxx::v_noabi::pipeline
A MongoDB aggregation pipeline.
Definition pipeline.hpp:45
mongocxx::v_noabi::read_concern
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
mongocxx::v_noabi::read_preference
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:59
mongocxx::v_noabi::search_index_view
A MongoDB Atlas Search Index.
Definition search_index_view.hpp:48
mongocxx::v_noabi::write_concern
The level of acknowledgment requested for write operations to a MongoDB server.
Definition write_concern.hpp:54
concatenate.hpp
Provides concatenators for use with "streaming" BSON builder syntax.
count.hpp
Provides mongocxx::v_noabi::options::count.
distinct.hpp
Provides mongocxx::v_noabi::options::distinct.
view_or_value.hpp
Provides bsoncxx::v_noabi::document::view_or_value.
estimated_document_count.hpp
Provides mongocxx::v_noabi::options::estimated_document_count.
find.hpp
Provides mongocxx::v_noabi::options::find.
find_one_and_delete.hpp
Provides mongocxx::v_noabi::options::find_one_and_delete.
find_one_and_replace.hpp
Provides mongocxx::v_noabi::options::find_one_and_replace.
find_one_and_update.hpp
Provides mongocxx::v_noabi::options::find_one_and_update.
index.hpp
Provides mongocxx::v_noabi::options::index.
index_view.hpp
Provides mongocxx::v_noabi::index_view.
insert.hpp
Provides mongocxx::v_noabi::options::insert.
insert_many.hpp
Provides mongocxx::v_noabi::result::insert_many.
kvp.hpp
Declares bsoncxx::v_noabi::builder::basic::kvp.
insert_one.hpp
Provides mongocxx::v_noabi::model::insert_one.
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx::v_noabi::builder::basic
Declares entities used with "basic" BSON builder syntax.
bsoncxx::v_noabi::builder::basic::make_document
v_noabi::document::value make_document(Args &&... args)
Creates a document from a list of key-value pairs.
Definition document.hpp:118
bsoncxx::v_noabi::builder::basic::kvp
std::tuple< T &&, U && > kvp(T &&t, U &&u)
Constructs a key-value pair from a string key and a BSON value.
Definition kvp.hpp:31
bsoncxx::v_noabi::document::view_or_value
v_noabi::view_or_value< v_noabi::document::view, v_noabi::document::value > view_or_value
Equivalent to v_noabi::view_or_value<v_noabi::document::view, v_noabi::document::value>.
Definition view_or_value.hpp:30
bsoncxx::v_noabi::stdx
Declares C++17 standard library polyfills.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
delete.hpp
Provides mongocxx::v_noabi::options::delete_options.
index_view.hpp
Provides mongocxx::v_noabi::options::index_view.
update.hpp
Provides mongocxx::v_noabi::options::update.
replace.hpp
Provides mongocxx::v_noabi::options::replace.
delete.hpp
Provides mongocxx::v_noabi::result::delete_result.
insert_one.hpp
Provides mongocxx::v_noabi::result::insert_one.
replace_one.hpp
Provides mongocxx::v_noabi::result::replace_one.
update.hpp
Provides mongocxx::v_noabi::result::update.
search_index_view.hpp
Provides mongocxx::v_noabi::search_index_view.
view_or_value.hpp
Provides bsoncxx::v_noabi::string::view_or_value.
collection.hpp
Provides mongocxx::v1::collection.
value.hpp
Provides bsoncxx::v_noabi::document::value.
oid.hpp
Provides bsoncxx::v_noabi::oid.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
bulk_write-fwd.hpp
Declares mongocxx::v_noabi::bulk_write.
bulk_write.hpp
Provides mongocxx::v_noabi::bulk_write.
change_stream.hpp
Provides mongocxx::v_noabi::change_stream.
client_encryption-fwd.hpp
Declares mongocxx::v_noabi::client_encryption.
client_session.hpp
Provides mongocxx::v_noabi::client_session.
collection-fwd.hpp
Declares mongocxx::v_noabi::collection.
cursor.hpp
Provides mongocxx::v_noabi::cursor.
database-fwd.hpp
Declares mongocxx::v_noabi::database.
bulk_write.hpp
Provides mongocxx::v_noabi::options::bulk_write.
change_stream.hpp
Provides mongocxx::v_noabi::options::change_stream.
pipeline.hpp
Provides mongocxx::v_noabi::pipeline.
read_concern.hpp
Provides mongocxx::v_noabi::read_concern.
read_preference.hpp
Provides mongocxx::v_noabi::read_preference.
bulk_write.hpp
Provides mongocxx::v_noabi::result::bulk_write.
write_concern.hpp
Provides mongocxx::v_noabi::write_concern.
write.hpp
Provides mongocxx::v_noabi::model::write.