MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
mongocxx::v_noabi::index_view Class Reference

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

Description

Class representing a MongoDB index view.

Public Member Functions

bsoncxx::v_noabi::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.
 
bsoncxx::v_noabi::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.
 
stdx::optional< std::string > create_one (const bsoncxx::v_noabi::document::view_or_value &keys, const bsoncxx::v_noabi::document::view_or_value &index_options={}, const options::index_view &options=options::index_view{})
 Creates an index. A convenience method that calls create_many.
 
stdx::optional< std::string > create_one (const client_session &session, const bsoncxx::v_noabi::document::view_or_value &keys, const bsoncxx::v_noabi::document::view_or_value &index_options={}, const options::index_view &options=options::index_view{})
 Creates an index. A convenience method that calls create_many.
 
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. A convenience method that calls create_many.
 
stdx::optional< std::string > create_one (const index_model &index, const options::index_view &options=options::index_view{})
 Creates an index. A convenience method that calls create_many.
 
void drop_all (const client_session &session, const options::index_view &options=options::index_view{})
 Drops all indexes in the collection.
 
void drop_all (const options::index_view &options=options::index_view{})
 Drops all indexes in the collection.
 
void drop_one (const bsoncxx::v_noabi::document::view_or_value &keys, const bsoncxx::v_noabi::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.
 
void drop_one (const client_session &session, const bsoncxx::v_noabi::document::view_or_value &keys, const bsoncxx::v_noabi::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.
 
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.
 
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.
 
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.
 
void drop_one (stdx::string_view name, const options::index_view &options=options::index_view{})
 Drops a single index by name.
 
cursor list ()
 Returns a cursor over all the indexes.
 
cursor list (const client_session &session)
 Returns a cursor over all the indexes.
 

Member Function Documentation

◆ create_many() [1/2]

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

Parameters
sessionThe mongocxx::v_noabi::client_session with which to perform the operation.
indexesstd::vector containing index models describing the indexes being created.
optionsOptional 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
Throwsoperation_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

◆ create_many() [2/2]

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

Adds a container of indexes to the collection.

Parameters
indexesstd::vector containing index models describing the indexes being created.
optionsOptional 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
Throwsoperation_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

◆ create_one() [1/4]

stdx::optional< std::string > mongocxx::v_noabi::index_view::create_one ( const bsoncxx::v_noabi::document::view_or_value & keys,
const bsoncxx::v_noabi::document::view_or_value & index_options = {},
const options::index_view & options = options::index_view{} )

Creates an index. A convenience method that calls create_many.

Parameters
keysA document containing the index keys and their corresponding index types.
index_optionsA document containing set of options that controls the creation of the index. See https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/.
optionsOptional 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
Throwsoperation_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

◆ create_one() [2/4]

stdx::optional< std::string > mongocxx::v_noabi::index_view::create_one ( const client_session & session,
const bsoncxx::v_noabi::document::view_or_value & keys,
const bsoncxx::v_noabi::document::view_or_value & index_options = {},
const options::index_view & options = options::index_view{} )

Creates an index. A convenience method that calls create_many.

Parameters
sessionThe mongocxx::v_noabi::client_session with which to perform the operation.
keysA document containing the index keys and their corresponding index types.
index_optionsA document containing set of options that controls the creation of the index. See https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/.
optionsOptional 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
Throwsoperation_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

◆ create_one() [3/4]

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

Creates an index. A convenience method that calls create_many.

Parameters
sessionThe mongocxx::v_noabi::client_session with which to perform the operation.
indexIndex_model describing the index being created.
optionsOptional 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
Throwsoperation_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

◆ create_one() [4/4]

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

Creates an index. A convenience method that calls create_many.

Parameters
indexIndex_model describing the index being created.
optionsOptional 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
Throwsoperation_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

◆ drop_all() [1/2]

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

Drops all indexes in the collection.

Parameters
sessionThe mongocxx::v_noabi::client_session with which to perform the drop.
optionsOptional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.
Exceptions
Throwsoperation_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

◆ drop_all() [2/2]

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

Drops all indexes in the collection.

Parameters
optionsOptional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.
Exceptions
Throwsoperation_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

◆ drop_one() [1/6]

void mongocxx::v_noabi::index_view::drop_one ( const bsoncxx::v_noabi::document::view_or_value & keys,
const bsoncxx::v_noabi::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.

Parameters
keysA 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.
optionsOptional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.
Exceptions
Throwsbsoncxx::v_noabi::exception if "name" key is present in options but is not a string.
Throwsoperation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
Throwslogic_error if "*" is passed in for the index name
See also

◆ drop_one() [2/6]

void mongocxx::v_noabi::index_view::drop_one ( const client_session & session,
const bsoncxx::v_noabi::document::view_or_value & keys,
const bsoncxx::v_noabi::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.

Parameters
sessionThe mongocxx::v_noabi::client_session with which to perform the drop.
keysA 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.
optionsOptional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.
Exceptions
Throwsbsoncxx::v_noabi::exception if "name" key is present in options but is not a string.
Throwsoperation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
Throwslogic_error if "*" is passed in for the index name
See also

◆ drop_one() [3/6]

void mongocxx::v_noabi::index_view::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.

Parameters
sessionThe mongocxx::v_noabi::client_session with which to perform the drop.
indexAn index model describing the index being dropped.
optionsOptional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.
Exceptions
Throwsbsoncxx::v_noabi::exception if "name" key is present in options but is not a string.
Throwsoperation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
Throwslogic_error if "*" is passed in for the index name
See also

◆ drop_one() [4/6]

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

Drops a single index by name.

Parameters
sessionThe mongocxx::v_noabi::client_session with which to perform the drop.
nameThe name of the index being dropped.
optionsOptional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.
Exceptions
Throwsoperation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
Throwslogic_error if "*" is passed in for the index name.
See also

◆ drop_one() [5/6]

void mongocxx::v_noabi::index_view::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.

Parameters
indexAn index model describing the index being dropped.
optionsOptional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.
Exceptions
Throwsbsoncxx::v_noabi::exception if "name" key is present in options but is not a string.
Throwsoperation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
Throwslogic_error if "*" is passed in for the index name
See also

◆ drop_one() [6/6]

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

Drops a single index by name.

Parameters
nameThe name of the index being dropped.
optionsOptional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.
Exceptions
Throwsoperation_exception for any errors encountered by the server or if max_time_ms option is present and the operation exceeds the time limit.
Throwslogic_error if "*" is passed in for the index name.
See also

◆ list() [1/2]

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

Returns a cursor over all the indexes.

◆ list() [2/2]

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

Returns a cursor over all the indexes.

Parameters
sessionThe mongocxx::v_noabi::client_session with which to perform the list operation.

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