Loading...
Searching...
No Matches
mongocxx::index_view Class Reference

`#include <mongocxx/v_noabi/mongocxx/index_view.hpp>`

## Description

A MongoDB index.

Note
  Not to be confused with a MongoDB Atlas Search Index (mongocxx::v_noabi::search_index_view).

## Public Member Functions

| index_view (v1::indexes indexes)
| Construct with the mongocxx::v1 equivalent.
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::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={})
| 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.
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.
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={})
| Creates an index. A convenience method that calls create_many.
bsoncxx::v_noabi::stdx::optional< std::string > | create_one (v_noabi::index_model const &index, v_noabi::options::index_view const &options={})
| Creates an index. A convenience method that calls create_many.
void | drop_all (options::index_view const &options={})
| Drops all indexes in the collection.
void | drop_all (v_noabi::client_session const &session, v_noabi::options::index_view const &options={})
| Drops all indexes in the collection.
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.
void | drop_one (bsoncxx::v_noabi::stdx::string_view name, v_noabi::options::index_view const &options={})
| Drops a single index by name.
void | drop_one (client_session const &session, index_model const &index, v_noabi::options::index_view const &options={})
| Attempts to drop a single index from the collection given an index model.
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.
void | drop_one (v_noabi::client_session const &session, bsoncxx::v_noabi::stdx::string_view name, v_noabi::options::index_view const &options={})
| Drops a single index by name.
void | drop_one (v_noabi::index_model const &index, v_noabi::options::index_view const &options={})
| Attempts to drop a single index from the collection given an index model.
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.
| operator v1::indexes () &&
| Convert to the mongocxx::v1 equivalent.
| operator v1::indexes () const &
| Convert to the mongocxx::v1 equivalent.

## Constructor & Destructor Documentation

## index_view()

mongocxx::v_noabi::index_view::index_view | ( | v1::indexes | indexes | ) |

inline

Construct with the mongocxx::v1 equivalent.

## Member Function Documentation

## create_many() [1/2]

bsoncxx::v_noabi::document::value mongocxx::v_noabi::index_view::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.

Parameters

  indexes | std::vector containing index models describing the indexes being created.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Returns
  The result document sent back by the server as if the createIndexes command was run from the shell.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## create_many() [2/2]

bsoncxx::v_noabi::document::value mongocxx::v_noabi::index_view::create_many | ( | v_noabi::client_session const & | session,
|  | std::vector< v_noabi::index_model > const & | indexes,
|  | v_noabi::options::index_view const & | options = {} )

Adds a container of indexes to the collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  indexes | std::vector containing index models describing the indexes being created.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Returns
  The result document sent back by the server as if the createIndexes command was run from the shell.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## create_one() [1/4]

bsoncxx::v_noabi::stdx::optional< std::string > mongocxx::v_noabi::index_view::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 = {} )

inline

Creates an index. A convenience method that calls create_many.

Parameters

  keys | A document containing the index keys and their corresponding index types.
  index_options | A document containing set of options that controls the creation of the index. See https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Returns
  An optional containing the name of the created index. If and index with the same keys already exists, an empty optional is returned.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.

See also
  - https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/

## create_one() [2/4]

bsoncxx::v_noabi::stdx::optional< std::string > mongocxx::v_noabi::index_view::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 = {} )

inline

Creates an index. A convenience method that calls create_many.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  keys | A document containing the index keys and their corresponding index types.
  index_options | A document containing set of options that controls the creation of the index. See https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Returns
  An optional containing the name of the created index. If and index with the same keys already exists, an empty optional is returned.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.

See also
  - https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/

## create_one() [3/4]

bsoncxx::v_noabi::stdx::optional< std::string > mongocxx::v_noabi::index_view::create_one | ( | v_noabi::client_session const & | session,
|  | index_model const & | index,
|  | v_noabi::options::index_view const & | options = {} )

Creates an index. A convenience method that calls create_many.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  index | Index_model describing the index being created.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Returns
  An optional containing the name of the created index. If and index with the same keys already exists, an empty optional is returned.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## create_one() [4/4]

bsoncxx::v_noabi::stdx::optional< std::string > mongocxx::v_noabi::index_view::create_one | ( | v_noabi::index_model const & | index,
|  | v_noabi::options::index_view const & | options = {} )

Creates an index. A convenience method that calls create_many.

Parameters

  index | Index_model describing the index being created.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Returns
  An optional containing the name of the created index. If and index with the same keys already exists, an empty optional is returned.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## drop_all() [1/2]

void mongocxx::v_noabi::index_view::drop_all | ( | options::index_view const & | options = {} | ) |

Drops all indexes in the collection.

Parameters

  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## drop_all() [2/2]

void mongocxx::v_noabi::index_view::drop_all | ( | v_noabi::client_session const & | session,
|  | v_noabi::options::index_view const & | options = {} )

Drops all indexes in the collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the drop.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## drop_one() [1/6]

void mongocxx::v_noabi::index_view::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 = {} )

inline

Attempts to drop a single index from the collection given the keys and options.

Parameters

  keys | A document containing the index keys and their corresponding index types. If no name option is present in the options, a name based on the keys will be used.
  index_options | (optional) A document containing set of options used to create the index. Only the name field will be used from here, and if it is not included, a name based on they keys will be used.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  Throws | bsoncxx::v_noabi::exception if "name" key is present in options but is not a string.
  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
  Throws | logic_error if "*" is passed in for the index name

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## drop_one() [2/6]

void mongocxx::v_noabi::index_view::drop_one | ( | bsoncxx::v_noabi::stdx::string_view | name,
|  | v_noabi::options::index_view const & | options = {} )

Drops a single index by name.

Parameters

  name | The name of the index being dropped.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
  Throws | logic_error if "*" is passed in for the index name.

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## drop_one() [3/6]

void mongocxx::v_noabi::index_view::drop_one | ( | client_session const & | session,
|  | index_model const & | index,
|  | v_noabi::options::index_view const & | options = {} )

Attempts to drop a single index from the collection given an index model.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the drop.
  index | An index model describing the index being dropped.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  Throws | bsoncxx::v_noabi::exception if "name" key is present in options but is not a string.
  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
  Throws | logic_error if "*" is passed in for the index name

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## drop_one() [4/6]

void mongocxx::v_noabi::index_view::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 = {} )

inline

Attempts to drop a single index from the collection given the keys and options.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the drop.
  keys | A document containing the index keys and their corresponding index types. If no name option is present in the options, a name based on the keys will be used.
  index_options | (optional) A document containing set of options used to create the index. Only the name field will be used from here, and if it is not included, a name based on they keys will be used.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  Throws | bsoncxx::v_noabi::exception if "name" key is present in options but is not a string.
  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
  Throws | logic_error if "*" is passed in for the index name

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## drop_one() [5/6]

void mongocxx::v_noabi::index_view::drop_one | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::stdx::string_view | name,
|  | v_noabi::options::index_view const & | options = {} )

Drops a single index by name.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the drop.
  name | The name of the index being dropped.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
  Throws | logic_error if "*" is passed in for the index name.

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## drop_one() [6/6]

void mongocxx::v_noabi::index_view::drop_one | ( | v_noabi::index_model const & | index,
|  | v_noabi::options::index_view const & | options = {} )

Attempts to drop a single index from the collection given an index model.

Parameters

  index | An index model describing the index being dropped.
  options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  Throws | bsoncxx::v_noabi::exception if "name" key is present in options but is not a string.
  Throws | operation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
  Throws | logic_error if "*" is passed in for the index name

See also
  - https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/

## list() [1/2]

v_noabi::cursor mongocxx::v_noabi::index_view::list | ( |  | ) |

Returns a cursor over all the indexes.

## list() [2/2]

v_noabi::cursor mongocxx::v_noabi::index_view::list | ( | v_noabi::client_session const & | session | ) |

Returns a cursor over all the indexes.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the list operation.

## operator v1::indexes() [1/2]

mongocxx::v_noabi::index_view::operator v1::indexes | ( |  | ) | &&

inline explicit

Convert to the mongocxx::v1 equivalent.

Postconditions:
  - *this is in an assign-or-destroy-only state.

Warning
  Invalidates all associated objects.

## operator v1::indexes() [2/2]

mongocxx::v_noabi::index_view::operator v1::indexes | ( |  | ) | const &

inline explicit

Convert to the mongocxx::v1 equivalent.

The documentation for this class was generated from the following file:

- mongocxx/v_noabi/mongocxx/index_view.hpp