MongoDB C++ Driver  mongocxx-3.7.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/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 
35 class MONGOCXX_API index_view {
36  public:
37  index_view(index_view&&) noexcept;
38  index_view& operator=(index_view&&) noexcept;
39 
40  ~index_view();
41 
47  cursor list();
48 
55  cursor list(const client_session& session);
56 
60 
84  stdx::optional<std::string> create_one(
86  const bsoncxx::document::view_or_value& index_options = {},
87  const options::index_view& options = options::index_view{});
88 
112  stdx::optional<std::string> create_one(
113  const client_session& session,
115  const bsoncxx::document::view_or_value& index_options = {},
116  const options::index_view& options = options::index_view{});
117 
121 
142  stdx::optional<std::string> create_one(
143  const index_model& index, const options::index_view& options = options::index_view{});
144 
165  stdx::optional<std::string> create_one(
166  const client_session& session,
167  const index_model& index,
168  const options::index_view& options = options::index_view{});
169 
173 
194  bsoncxx::document::value create_many(
195  const std::vector<index_model>& indexes,
196  const options::index_view& options = options::index_view{});
197 
218  bsoncxx::document::value create_many(
219  const client_session& session,
220  const std::vector<index_model>& indexes,
221  const options::index_view& options = options::index_view{});
222 
226 
245  void drop_one(stdx::string_view name,
246  const options::index_view& options = options::index_view{});
247 
266  void drop_one(const client_session& session,
267  stdx::string_view name,
268  const options::index_view& options = options::index_view{});
269 
273 
298  void drop_one(const bsoncxx::document::view_or_value& keys,
299  const bsoncxx::document::view_or_value& index_options = {},
300  const options::index_view& options = options::index_view{});
301 
326  void drop_one(const client_session& session,
328  const bsoncxx::document::view_or_value& index_options = {},
329  const options::index_view& options = options::index_view{});
330 
334 
355  void drop_one(const index_model& index,
356  const options::index_view& options = options::index_view{});
357 
378  void drop_one(const client_session& session,
379  const index_model& index,
380  const options::index_view& options = options::index_view{});
381 
385 
400  void drop_all(const options::index_view& options = options::index_view{});
401 
416  void drop_all(const client_session& session,
417  const options::index_view& options = options::index_view{});
418 
422 
423  private:
424  friend class collection;
425  class MONGOCXX_PRIVATE impl;
426 
427  MONGOCXX_PRIVATE index_view(void* coll, void* client);
428 
429  MONGOCXX_PRIVATE impl& _get_impl();
430 
431  private:
432  std::unique_ptr<impl> _impl;
433 };
434 
435 MONGOCXX_INLINE_NAMESPACE_END
436 } // namespace mongocxx
437 
438 #include <mongocxx/config/postlude.hpp>
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
bsoncxx::view_or_value< document::view, document::value >
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:34
mongocxx::index_view
Class representing a MongoDB index view.
Definition: index_view.hpp:35
mongocxx::client_session
Use a session for a sequence of operations, optionally with either causal consistency or snapshots.
Definition: client_session.hpp:40
mongocxx::collection
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:83
mongocxx::cursor
Class representing a pointer to the result set of a query on a MongoDB server.
Definition: cursor.hpp:36