MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
index_view.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/index_view-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/indexes.hpp> // IWYU pragma: export
22
23#include <string>
24#include <utility>
25#include <vector>
26
27#include <mongocxx/collection-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
28
33
35#include <mongocxx/cursor.hpp>
38
40
41namespace mongocxx {
42namespace v_noabi {
43
50class index_view {
51 private:
52 v1::indexes _indexes;
53
54 public:
55 index_view(index_view&& other) noexcept = default;
56 index_view& operator=(index_view&& other) noexcept = default;
57
58 ~index_view() = default;
59
60 index_view(index_view const& other) = delete;
61 index_view& operator=(index_view const& other) = delete;
62
66 /* explicit(false) */ index_view(v1::indexes indexes) : _indexes{std::move(indexes)} {}
67
76 explicit operator v1::indexes() && {
77 return std::move(_indexes);
78 }
79
83 explicit operator v1::indexes() const& {
84 return _indexes;
85 }
86
91
99
128
154 v_noabi::client_session const& session,
156 bsoncxx::v_noabi::document::view_or_value const& index_options = {},
158 return this->create_one(session, v_noabi::index_model{keys, index_options}, options);
159 }
160
180 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::string>)
181 create_one(v_noabi::index_model const& index, v_noabi::options::index_view const& options = {});
182
206 v_noabi::client_session const& session,
207 index_model const& index,
208 v_noabi::options::index_view const& options = {});
209
230 create_many(std::vector<v_noabi::index_model> const& indexes, v_noabi::options::index_view const& options = {});
231
255 v_noabi::client_session const& session,
256 std::vector<v_noabi::index_model> const& indexes,
257 v_noabi::options::index_view const& options = {});
258
277 drop_one(bsoncxx::v_noabi::stdx::string_view name, v_noabi::options::index_view const& options = {});
278
300 v_noabi::client_session const& session,
301 bsoncxx::v_noabi::stdx::string_view name,
302 v_noabi::options::index_view const& options = {});
303
330 bsoncxx::v_noabi::document::view_or_value const& index_options = {},
332 return this->drop_one(v_noabi::index_model{std::move(keys), std::move(index_options)}, options);
333 }
334
362 v_noabi::client_session const& session,
364 bsoncxx::v_noabi::document::view_or_value const& index_options = {},
366 return this->drop_one(session, v_noabi::index_model{std::move(keys), std::move(index_options)}, options);
367 }
368
390 drop_one(v_noabi::index_model const& index, v_noabi::options::index_view const& options = {});
391
415 drop_one(client_session const& session, index_model const& index, v_noabi::options::index_view const& options = {});
416
431 drop_all(options::index_view const& options = {});
432
449 drop_all(v_noabi::client_session const& session, v_noabi::options::index_view const& options = {});
450};
451
452} // namespace v_noabi
453} // namespace mongocxx
454
455namespace mongocxx {
456namespace v_noabi {
457
462 return {std::move(v)};
463}
464
469 return v1::indexes{std::move(v)};
470}
471
472} // namespace v_noabi
473} // namespace mongocxx
474
476
A polyfill for std::optional<T>.
Definition optional.hpp:799
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:48
Support for MongoDB indexes.
Definition indexes.hpp:58
Supports MongoDB client session operations.
Definition client_session.hpp:58
A cursor over the documents returned by a query to a MongoDB server.
Definition cursor.hpp:50
Used by mongocxx::v_noabi::index_view.
Definition index_model.hpp:32
A MongoDB index.
Definition index_view.hpp:50
void drop_one(bsoncxx::v_noabi::stdx::string_view name, v_noabi::options::index_view const &options={})
Drops a single index by name.
v_noabi::cursor list()
Returns a cursor over all the indexes.
v_noabi::cursor list(v_noabi::client_session const &session)
Returns a cursor over all the indexes.
index_view(v1::indexes indexes)
Construct with the mongocxx::v1 equivalent.
Definition index_view.hpp:66
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
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.
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
void drop_all(options::index_view const &options={})
Drops all indexes in the collection.
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
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
operator v1::indexes() &&
Convert to the mongocxx::v1 equivalent.
Definition index_view.hpp:76
Used by MongoDB index view operations.
Definition index_view.hpp:45
Provides bsoncxx::v_noabi::document::view_or_value.
Provides mongocxx::v_noabi::index_model.
Declares mongocxx::v_noabi::index_view.
Provides mongocxx::v1::indexes.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
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
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v_noabi::options::index_view.
Provides bsoncxx::v_noabi::document::value.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Provides mongocxx::v_noabi::client_session.
Declares mongocxx::v_noabi::collection.
Provides mongocxx::v_noabi::cursor.