Loading...
Searching...
No Matches
index_view.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/index_view-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/indexes.hpp> // IWYU pragma: export
#include <string>
#include <utility>
#include <vector>
#include <mongocxx/collection-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/document/view_or_value.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/stdx/string_view.hpp>
#include <mongocxx/client_session.hpp>
#include <mongocxx/cursor.hpp>
#include <mongocxx/index_model.hpp>
#include <mongocxx/options/index_view.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
class index_view {
private:
v1::indexes _indexes;
public:
index_view(index_view&& other) noexcept = default;
index_view& operator=(index_view&& other) noexcept = default;
~index_view() = default;
index_view(index_view const& other) = delete;
index_view& operator=(index_view const& other) = delete;
/* explicit(false) */ index_view(v1::indexes indexes) : _indexes{std::move(indexes)} {}
explicit operator v1::indexes() && {
return std::move(_indexes);
}
explicit operator v1::indexes() const& {
return _indexes;
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor) list();
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor) list(v_noabi::client_session const& session);
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 = {}) {
return this->create_one(v_noabi::index_model{keys, index_options}, options);
}
bsoncxx::v_noabi::stdx::optional<std::string> create_one(
v_noabi::client_session const& session,
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 = {}) {
return this->create_one(session, v_noabi::index_model{keys, index_options}, options);
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<std::string>)
create_one(v_noabi::index_model const& index, v_noabi::options::index_view const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<std::string>)
create_one(
v_noabi::client_session const& session,
index_model const& index,
v_noabi::options::index_view const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::document::value)
create_many(std::vector<v_noabi::index_model> const& indexes, v_noabi::options::index_view const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::document::value)
create_many(
v_noabi::client_session const& session,
std::vector<v_noabi::index_model> const& indexes,
v_noabi::options::index_view const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop_one(bsoncxx::v_noabi::stdx::string_view name, v_noabi::options::index_view const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop_one(
v_noabi::client_session const& session,
bsoncxx::v_noabi::stdx::string_view name,
v_noabi::options::index_view const& options = {});
void drop_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 = {}) {
return this->drop_one(v_noabi::index_model{std::move(keys), std::move(index_options)}, options);
}
void drop_one(
v_noabi::client_session const& session,
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 = {}) {
return this->drop_one(session, v_noabi::index_model{std::move(keys), std::move(index_options)}, options);
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop_one(v_noabi::index_model const& index, v_noabi::options::index_view const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop_one(client_session const& session, index_model const& index, v_noabi::options::index_view const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop_all(options::index_view const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop_all(v_noabi::client_session const& session, v_noabi::options::index_view const& options = {});
};
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::index_view from_v1(v1::indexes v) {
return {std::move(v)};
}
inline v1::indexes to_v1(v_noabi::index_view v) {
return v1::indexes{std::move(v)};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
bsoncxx::v_noabi::document::value
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:48
mongocxx::v1::indexes
Support for MongoDB indexes.
Definition indexes.hpp:56
mongocxx::v_noabi::client_session
Supports MongoDB client session operations.
Definition client_session.hpp:58
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_model
Used by mongocxx::v_noabi::index_view.
Definition index_model.hpp:32
mongocxx::v_noabi::index_view
A MongoDB index.
Definition index_view.hpp:50
mongocxx::v_noabi::index_view::drop_one
void drop_one(bsoncxx::v_noabi::stdx::string_view name, v_noabi::options::index_view const &options={})
Drops a single index by name.
mongocxx::v_noabi::index_view::list
v_noabi::cursor list()
Returns a cursor over all the indexes.
mongocxx::v_noabi::index_view::list
v_noabi::cursor list(v_noabi::client_session const &session)
Returns a cursor over all the indexes.
mongocxx::v_noabi::index_view::index_view
index_view(v1::indexes indexes)
Construct with the mongocxx::v1 equivalent.
Definition index_view.hpp:66
mongocxx::v_noabi::index_view::drop_one
void drop_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={})
Attempts to drop a single index from the collection given the keys and options.
Definition index_view.hpp:328
mongocxx::v_noabi::index_view::create_many
bsoncxx::v_noabi::document::value create_many(std::vector< v_noabi::index_model > const &indexes, v_noabi::options::index_view const &options={})
Adds a container of indexes to the collection.
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::index_view::drop_all
void drop_all(options::index_view const &options={})
Drops all indexes in the collection.
mongocxx::v_noabi::index_view::drop_one
void drop_one(v_noabi::client_session const &session, 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={})
Attempts to drop a single index from the collection given the keys and options.
Definition index_view.hpp:361
mongocxx::v_noabi::index_view::create_one
bsoncxx::v_noabi::stdx::optional< std::string > create_one(v_noabi::client_session const &session, 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:153
mongocxx::v_noabi::index_view::indexes
operator v1::indexes() &&
Convert to the mongocxx::v1 equivalent.
Definition index_view.hpp:76
mongocxx::v_noabi::options::index_view
Used by MongoDB index view operations.
Definition index_view.hpp:45
view_or_value.hpp
Provides bsoncxx::v_noabi::document::view_or_value.
index_model.hpp
Provides mongocxx::v_noabi::index_model.
index_view-fwd.hpp
Declares mongocxx::v_noabi::index_view.
indexes.hpp
Provides mongocxx::v1::indexes.
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::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
The top-level namespace within which all bsoncxx library entities are declared.
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.
index_view.hpp
Provides mongocxx::v_noabi::options::index_view.
value.hpp
Provides bsoncxx::v_noabi::document::value.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
client_session.hpp
Provides mongocxx::v_noabi::client_session.
collection-fwd.hpp
Declares mongocxx::v_noabi::collection.
cursor.hpp
Provides mongocxx::v_noabi::cursor.