MongoDB C++ Driver  mongocxx-3.2.0
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/cursor.hpp>
23 #include <mongocxx/index_model.hpp>
24 #include <mongocxx/options/index_view.hpp>
25 
26 #include <mongocxx/config/prelude.hpp>
27 
28 namespace mongocxx {
29 MONGOCXX_INLINE_NAMESPACE_BEGIN
30 
31 class MONGOCXX_API index_view {
32  public:
33  index_view(index_view&&) noexcept;
34  index_view& operator=(index_view&&) noexcept;
35 
36  ~index_view();
37 
41  cursor list();
42 
64  stdx::optional<std::string> create_one(
66  const bsoncxx::document::view_or_value& index_options = {},
67  const options::index_view& options = options::index_view{});
68 
87  stdx::optional<std::string> create_one(
88  const index_model& index, const options::index_view& options = options::index_view{});
89 
108  bsoncxx::document::value create_many(
109  const std::vector<index_model>& indexes,
110  const options::index_view& options = options::index_view{});
111 
128  void drop_one(stdx::string_view name,
129  const options::index_view& options = options::index_view{});
130 
153  void drop_one(const bsoncxx::document::view_or_value& keys,
154  const bsoncxx::document::view_or_value& index_options = {},
155  const options::index_view& options = options::index_view{});
156 
175  void drop_one(const index_model& index,
176  const options::index_view& options = options::index_view{});
177 
190  void drop_all(const options::index_view& options = options::index_view{});
191 
192  private:
193  friend class collection;
194  class MONGOCXX_PRIVATE impl;
195 
196  MONGOCXX_PRIVATE index_view(void* coll);
197 
198  MONGOCXX_PRIVATE impl& _get_impl();
199 
200  private:
201  std::unique_ptr<impl> _impl;
202 };
203 
204 MONGOCXX_INLINE_NAMESPACE_END
205 } // namespace mongocxx
206 
207 #include <mongocxx/config/postlude.hpp>
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:22
A read-only BSON document that owns its underlying buffer.
Definition: value.hpp:33
Class representing a pointer to the result set of a query on a MongoDB server.
Definition: cursor.hpp:36
Definition: index_view.hpp:31
Class representing optional arguments to IndexView operations.
Definition: index_view.hpp:31
Class representing an index on a MongoDB server.
Definition: index_model.hpp:29
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:84