Loading...
Searching...
No Matches
mongocxx::v1::indexes Class Reference

`#include <mongocxx/v1/indexes.hpp>`

## Description

Support for MongoDB indexes.

Note
  Not to be confused with Atlas Search indexes or Atlas Vector Search indexes.

See also
  - Indexes (MongoDB Manual)

## Classes

class | create_many_options
| Options for mongocxx::v1::indexes::create_many. More...
class | create_one_options
| Options for mongocxx::v1::indexes::create_one. More...
class | drop_all_options
| Options for mongocxx::v1::indexes::drop_all. More...
class | drop_one_options
| Options for mongocxx::v1::indexes::drop_one. More...
class | list_options
| Options for mongocxx::v1::indexes::list. More...
class | model
| A description of a MongoDB index. More...
class | options
| Options for mongocxx::v1::indexes::model. More...

## Public Types

enum class | errc
| Errors codes which may be returned by mongocxx::v1::indexes. More...

## Public Member Functions

| indexes (indexes &&other) noexcept
| Move constructor.
| indexes (indexes const &other)
| Copy constructor.
| ~indexes ()
| Destroy this object.
bsoncxx::v1::document::value | create_many (std::vector< model > const &indexes, create_many_options const &create_opts={})
| Create multiple indexes in the associated collection.
bsoncxx::v1::document::value | create_many (v1::client_session const &session, std::vector< model > const &indexes, create_many_options const &create_opts={})
| Create multiple indexes in the associated collection.
bsoncxx::v1::stdx::optional< std::string > | create_one (bsoncxx::v1::document::value keys, bsoncxx::v1::document::value index_opts={}, create_one_options const &create_opts={})
| Equivalent to this->create_one(model(keys, index_opts), create_opts).
bsoncxx::v1::stdx::optional< std::string > | create_one (model const &index, create_one_options const &create_opts={})
| Create a single index in the associated collection.
bsoncxx::v1::stdx::optional< std::string > | create_one (v1::client_session const &session, bsoncxx::v1::document::value keys, bsoncxx::v1::document::value index_opts={}, create_one_options const &create_opts={})
| Equivalent to this->create_one(session, model(keys, index_opts), create_opts).
bsoncxx::v1::stdx::optional< std::string > | create_one (v1::client_session const &session, model const &index, create_one_options const &create_opts={})
| Create a single index in the associated collection.
void | drop_all (drop_all_options const &drop_opts={})
| Drop all indexes in the associated collection.
void | drop_all (v1::client_session const &session, drop_all_options const &drop_opts={})
| Drop all indexes in the associated collection.
void | drop_one (bsoncxx::v1::document::value keys, bsoncxx::v1::document::value index_opts={}, drop_one_options const &drop_opts={})
| Equivalent to this->drop_one(mongocxx::v1::indexes::model(keys, index_opts), drop_opts).
void | drop_one (bsoncxx::v1::stdx::string_view index, drop_one_options const &drop_opts={})
| Drop a single index in the associated collection.
void | drop_one (client_session const &session, bsoncxx::v1::document::value keys, bsoncxx::v1::document::value index_opts={}, drop_one_options const &drop_opts={})
| Equivalent to this->drop_one(session, mongocxx::v1::indexes::model(keys, index_opts), drop_opts).
void | drop_one (model const &index, drop_one_options const &drop_opts={})
| Drop a single index in the associated collection.
void | drop_one (v1::client_session const &session, bsoncxx::v1::stdx::string_view index, drop_one_options const &drop_opts={})
| Drop a single index in the associated collection.
void | drop_one (v1::client_session const &session, model const &index, drop_one_options const &drop_opts={})
| Drop a single index in the associated collection.
v1::cursor | list (list_options const &list_opts={})
| Return all indexes in the associated collection.
v1::cursor | list (v1::client_session const &session, list_options const &list_opts={})
| Return all indexes in the associated collection.
indexes & | operator= (indexes &&other) noexcept
| Move assignment.
indexes & | operator= (indexes const &other)
| Copy assignment.

## Static Public Member Functions

static std::error_category const & | error_category ()
| The error category for mongocxx::v1::instance::errc.

## Friends

std::error_code | make_error_code (errc v)
| Support implicit conversion to std::error_code.

## Member Enumeration Documentation

## errc

enum class mongocxx::v1::indexes::errc

strong

Errors codes which may be returned by mongocxx::v1::indexes.

Enumerator
zero | Zero.
expired_after_i32 | The "expiredAfterSeconds" field must be representable as an std::int32_t.
invalid_name | "*" is not a permitted index name.

## Constructor & Destructor Documentation

## ~indexes()

mongocxx::v1::indexes::~indexes | ( |  | ) |

Destroy this object.

Warning
  Invalidates all associated views.

## indexes() [1/2]

mongocxx::v1::indexes::indexes | ( | indexes && | other | ) |

noexcept

Move constructor.

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

## indexes() [2/2]

mongocxx::v1::indexes::indexes | ( | indexes const & | other | ) |

Copy constructor.

## Member Function Documentation

## create_many() [1/2]

bsoncxx::v1::document::value mongocxx::v1::indexes::create_many | ( | std::vector< model > const & | indexes,
|  | create_many_options const & | create_opts = {} )

Create multiple indexes in the associated collection.

Parameters

  indexes | The definitions of the new indexes. The options must be applicable to the "createIndexes" command.
  create_opts | "createIndexes" command options.

Returns
  The raw server response.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## create_many() [2/2]

bsoncxx::v1::document::value mongocxx::v1::indexes::create_many | ( | v1::client_session const & | session,
|  | std::vector< model > const & | indexes,
|  | create_many_options const & | create_opts = {} )

Create multiple indexes in the associated collection.

Parameters

  session | The session with which this operation is associated.
  indexes | The definitions of the new indexes. The options must be applicable to the "createIndexes" command.
  create_opts | "createIndexes" command options.

Returns
  The raw server response.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## create_one() [1/4]

bsoncxx::v1::stdx::optional< std::string > mongocxx::v1::indexes::create_one | ( | bsoncxx::v1::document::value | keys,
|  | bsoncxx::v1::document::value | index_opts = {},
|  | create_one_options const & | create_opts = {} )

inline

Equivalent to this->create_one(model(keys, index_opts), create_opts).

## create_one() [2/4]

bsoncxx::v1::stdx::optional< std::string > mongocxx::v1::indexes::create_one | ( | model const & | index,
|  | create_one_options const & | create_opts = {} )

Create a single index in the associated collection.

Equivalent to this->create_many(...) with a single index model.

Parameters

  index | The definition of the new index. The options must be applicable to the "createIndexes" command.
  create_opts | "createIndexes" command options.

Returns
  The name of the created index. Empty when the index already exists.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## create_one() [3/4]

bsoncxx::v1::stdx::optional< std::string > mongocxx::v1::indexes::create_one | ( | v1::client_session const & | session,
|  | bsoncxx::v1::document::value | keys,
|  | bsoncxx::v1::document::value | index_opts = {},
|  | create_one_options const & | create_opts = {} )

inline

Equivalent to this->create_one(session, model(keys, index_opts), create_opts).

## create_one() [4/4]

bsoncxx::v1::stdx::optional< std::string > mongocxx::v1::indexes::create_one | ( | v1::client_session const & | session,
|  | model const & | index,
|  | create_one_options const & | create_opts = {} )

Create a single index in the associated collection.

Equivalent to this->create_many(...) with a single index model.

Parameters

  session | The session with which this operation is associated.
  index | The definition of the new index. The options must be applicable to the "createIndexes" command.
  create_opts | "createIndexes" command options.

Returns
  The name of the created index. Empty when the index already exists.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## drop_all() [1/2]

void mongocxx::v1::indexes::drop_all | ( | drop_all_options const & | drop_opts = {} | ) |

Drop all indexes in the associated collection.

Parameters

  drop_opts | "dropIndexes" command options.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## drop_all() [2/2]

void mongocxx::v1::indexes::drop_all | ( | v1::client_session const & | session,
|  | drop_all_options const & | drop_opts = {} )

Drop all indexes in the associated collection.

Parameters

  session | The session with which this operation is associated.
  drop_opts | "dropIndexes" command options.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## drop_one() [1/6]

void mongocxx::v1::indexes::drop_one | ( | bsoncxx::v1::document::value | keys,
|  | bsoncxx::v1::document::value | index_opts = {},
|  | drop_one_options const & | drop_opts = {} )

inline

Equivalent to this->drop_one(mongocxx::v1::indexes::model(keys, index_opts), drop_opts).

## drop_one() [2/6]

void mongocxx::v1::indexes::drop_one | ( | bsoncxx::v1::stdx::string_view | index,
|  | drop_one_options const & | drop_opts = {} )

Drop a single index in the associated collection.

Parameters

  index | The name of index to drop.
  drop_opts | "dropIndexes" command options.

Exceptions

  mongocxx::v1::exception | with mongocxx::v1::indexes::errc::invalid_name if name is equal to "*".
  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## drop_one() [3/6]

void mongocxx::v1::indexes::drop_one | ( | client_session const & | session,
|  | bsoncxx::v1::document::value | keys,
|  | bsoncxx::v1::document::value | index_opts = {},
|  | drop_one_options const & | drop_opts = {} )

inline

Equivalent to this->drop_one(session, mongocxx::v1::indexes::model(keys, index_opts), drop_opts).

## drop_one() [4/6]

void mongocxx::v1::indexes::drop_one | ( | model const & | index,
|  | drop_one_options const & | drop_opts = {} )

Drop a single index in the associated collection.

Parameters

  index | The description of the index to drop.
  drop_opts | "dropIndexes" command options.

Exceptions

  mongocxx::v1::exception | with mongocxx::v1::indexes::errc::invalid_name if name is equal to "*".
  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## drop_one() [5/6]

void mongocxx::v1::indexes::drop_one | ( | v1::client_session const & | session,
|  | bsoncxx::v1::stdx::string_view | index,
|  | drop_one_options const & | drop_opts = {} )

Drop a single index in the associated collection.

Parameters

  session | The session with which this operation is associated.
  index | The name of index to drop.
  drop_opts | "dropIndexes" command options.

Exceptions

  mongocxx::v1::exception | with mongocxx::v1::indexes::errc::invalid_name if name is equal to "*".
  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## drop_one() [6/6]

void mongocxx::v1::indexes::drop_one | ( | v1::client_session const & | session,
|  | model const & | index,
|  | drop_one_options const & | drop_opts = {} )

Drop a single index in the associated collection.

Parameters

  session | The session with which this operation is associated.
  index | The description of the index to drop.
  drop_opts | "dropIndexes" command options.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## error_category()

std::error_category const & mongocxx::v1::indexes::error_category | ( |  | ) |

static

The error category for mongocxx::v1::instance::errc.

## list() [1/2]

v1::cursor mongocxx::v1::indexes::list | ( | list_options const & | list_opts = {} | ) |

Return all indexes in the associated collection.

Parameters

  list_opts | "listIndexes" command options.

## list() [2/2]

v1::cursor mongocxx::v1::indexes::list | ( | v1::client_session const & | session,
|  | list_options const & | list_opts = {} )

Return all indexes in the associated collection.

Parameters

  session | The session with which this operation is associated.
  list_opts | "listIndexes" command options.

## operator=() [1/2]

indexes & mongocxx::v1::indexes::operator= | ( | indexes && | other | ) |

noexcept

Move assignment.

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

## operator=() [2/2]

indexes & mongocxx::v1::indexes::operator= | ( | indexes const & | other | ) |

Copy assignment.

## Friends And Related Symbol Documentation

## make_error_code

std::error_code make_error_code | ( | errc | v | ) |

friend

Support implicit conversion to std::error_code.

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

- mongocxx/v1/indexes.hpp