MongoDB C++ Driver  mongocxx-3.6.2
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
index_view.hpp
1 // Copyright 2017 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 <string>
18 #include <vector>
19 
20 #include <bsoncxx/document/value.hpp>
21 #include <bsoncxx/stdx/optional.hpp>
22 #include <mongocxx/client_session.hpp>
23 #include <mongocxx/cursor.hpp>
24 #include <mongocxx/index_model.hpp>
25 #include <mongocxx/options/index_view.hpp>
26 
27 #include <mongocxx/config/prelude.hpp>
28 
29 namespace mongocxx {
30 MONGOCXX_INLINE_NAMESPACE_BEGIN
31 
32 class MONGOCXX_API index_view {
33  public:
34  index_view(index_view&&) noexcept;
35  index_view& operator=(index_view&&) noexcept;
36 
37  ~index_view();
38 
45 
52  cursor list(const client_session& session);
53 
57 
81  stdx::optional<std::string> create_one(
83  const bsoncxx::document::view_or_value& index_options = {},
84  const options::index_view& options = options::index_view{});
85 
109  stdx::optional<std::string> create_one(
110  const client_session& session,
112  const bsoncxx::document::view_or_value& index_options = {},
113  const options::index_view& options = options::index_view{});
114 
118 
139  stdx::optional<std::string> create_one(
140  const index_model& index, const options::index_view& options = options::index_view{});
141 
162  stdx::optional<std::string> create_one(
163  const client_session& session,
164  const index_model& index,
165  const options::index_view& options = options::index_view{});
166 
170 
192  const std::vector<index_model>& indexes,
193  const options::index_view& options = options::index_view{});
194 
216  const client_session& session,
217  const std::vector<index_model>& indexes,
218  const options::index_view& options = options::index_view{});
219 
223 
242  void drop_one(stdx::string_view name,
243  const options::index_view& options = options::index_view{});
244 
263  void drop_one(const client_session& session,
264  stdx::string_view name,
265  const options::index_view& options = options::index_view{});
266 
270 
296  const bsoncxx::document::view_or_value& index_options = {},
297  const options::index_view& options = options::index_view{});
298 
323  void drop_one(const client_session& session,
325  const bsoncxx::document::view_or_value& index_options = {},
326  const options::index_view& options = options::index_view{});
327 
331 
352  void drop_one(const index_model& index,
353  const options::index_view& options = options::index_view{});
354 
375  void drop_one(const client_session& session,
376  const index_model& index,
377  const options::index_view& options = options::index_view{});
378 
382 
398 
413  void drop_all(const client_session& session,
414  const options::index_view& options = options::index_view{});
415 
419 
420  private:
421  friend class collection;
422  class MONGOCXX_PRIVATE impl;
423 
424  MONGOCXX_PRIVATE index_view(void* coll, void* client);
425 
426  MONGOCXX_PRIVATE impl& _get_impl();
427 
428  private:
429  std::unique_ptr<impl> _impl;
430 };
431 
432 MONGOCXX_INLINE_NAMESPACE_END
433 } // namespace mongocxx
434 
435 #include <mongocxx/config/postlude.hpp>
mongocxx::index_view::create_one
stdx::optional< std::string > create_one(const index_model &index, const options::index_view &options=options::index_view{})
Creates an index.
mongocxx::index_view::create_one
stdx::optional< std::string > create_one(const bsoncxx::document::view_or_value &keys, const bsoncxx::document::view_or_value &index_options={}, const options::index_view &options=options::index_view{})
Creates an index.
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::index_view::create_many
bsoncxx::document::value create_many(const std::vector< index_model > &indexes, const options::index_view &options=options::index_view{})
Adds a container of indexes to the collection.
bsoncxx::view_or_value< document::view, document::value >
mongocxx::index_view::drop_one
void drop_one(const bsoncxx::document::view_or_value &keys, const bsoncxx::document::view_or_value &index_options={}, const options::index_view &options=options::index_view{})
Attempts to drop a single index from the collection given the keys and options.
mongocxx::index_model
Class representing an index on a MongoDB server.
Definition: index_model.hpp:29
mongocxx::client
Class representing a client connection to MongoDB.
Definition: client.hpp:58
mongocxx::options::index_view
Class representing optional arguments to IndexView operations.
Definition: index_view.hpp:31
bsoncxx::document::value
A read-only BSON document that owns its underlying buffer.
Definition: value.hpp:33
mongocxx::index_view::drop_all
void drop_all(const options::index_view &options=options::index_view{})
Drops all indexes in the collection.
mongocxx::index_view
Definition: index_view.hpp:32
mongocxx::index_view::drop_one
void drop_one(const client_session &session, const bsoncxx::document::view_or_value &keys, const bsoncxx::document::view_or_value &index_options={}, const options::index_view &options=options::index_view{})
Attempts to drop a single index from the collection given the keys and options.
mongocxx::index_view::drop_one
void drop_one(const client_session &session, const index_model &index, const options::index_view &options=options::index_view{})
Attempts to drop a single index from the collection given an index model.
mongocxx::index_view::create_one
stdx::optional< std::string > create_one(const client_session &session, const bsoncxx::document::view_or_value &keys, const bsoncxx::document::view_or_value &index_options={}, const options::index_view &options=options::index_view{})
Creates an index.
mongocxx::client_session
Use a session for a sequence of operations, optionally with causal consistency.
Definition: client_session.hpp:39
mongocxx::index_view::create_many
bsoncxx::document::value create_many(const client_session &session, const std::vector< index_model > &indexes, const options::index_view &options=options::index_view{})
Adds a container of indexes to the collection.
mongocxx::index_view::drop_one
void drop_one(const client_session &session, stdx::string_view name, const options::index_view &options=options::index_view{})
Drops a single index by name.
mongocxx::index_view::list
cursor list(const client_session &session)
Returns a cursor over all the indexes.
mongocxx::index_view::list
cursor list()
Returns a cursor over all the indexes.
mongocxx::index_view::drop_one
void drop_one(stdx::string_view name, const options::index_view &options=options::index_view{})
Drops a single index by name.
mongocxx::index_view::create_one
stdx::optional< std::string > create_one(const client_session &session, const index_model &index, const options::index_view &options=options::index_view{})
Creates an index.
mongocxx::collection
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:81
mongocxx::index_view::drop_all
void drop_all(const client_session &session, const options::index_view &options=options::index_view{})
Drops all indexes in the collection.
mongocxx::index_view::drop_one
void drop_one(const index_model &index, const options::index_view &options=options::index_view{})
Attempts to drop a single index from the collection given an index model.
mongocxx::cursor
Class representing a pointer to the result set of a query on a MongoDB server.
Definition: cursor.hpp:36