MongoDB C++ Driver
mongocxx-3.7.0
|
Class representing a MongoDB index view. More...
#include <index_view.hpp>
Public Member Functions | |
cursor | list () |
Returns a cursor over all the indexes. | |
cursor | list (const client_session &session) |
Returns a cursor over all the indexes. More... | |
stdx::optional< std::string > | create_one (const bsoncxx::document::view_or_value &keys, const bsoncxx::document::view_or_value &index_options={}, const options::index_view &options=options::index_view{}) |
Creates an index. More... | |
stdx::optional< std::string > | create_one (const client_session &session, const bsoncxx::document::view_or_value &keys, const bsoncxx::document::view_or_value &index_options={}, const options::index_view &options=options::index_view{}) |
Creates an index. More... | |
stdx::optional< std::string > | create_one (const index_model &index, const options::index_view &options=options::index_view{}) |
Creates an index. More... | |
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. More... | |
bsoncxx::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. More... | |
bsoncxx::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. More... | |
void | drop_one (stdx::string_view name, const options::index_view &options=options::index_view{}) |
Drops a single index by name. More... | |
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. More... | |
void | drop_one (const bsoncxx::document::view_or_value &keys, const bsoncxx::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. More... | |
void | drop_one (const client_session &session, const bsoncxx::document::view_or_value &keys, const bsoncxx::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. More... | |
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. More... | |
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. More... | |
void | drop_all (const options::index_view &options=options::index_view{}) |
Drops all indexes in the collection. More... | |
void | drop_all (const client_session &session, const options::index_view &options=options::index_view{}) |
Drops all indexes in the collection. More... | |
Class representing a MongoDB index view.
bsoncxx::document::value mongocxx::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.
session | The mongocxx::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::options::index_view. |
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. |
bsoncxx::document::value mongocxx::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.
indexes | std::vector containing index models describing the indexes being created. |
options | Optional arguments for the overall operation, see mongocxx::options::index_view. |
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. |
stdx::optional<std::string> mongocxx::index_view::create_one | ( | const bsoncxx::document::view_or_value & | keys, |
const bsoncxx::document::view_or_value & | index_options = {} , |
||
const options::index_view & | options = options::index_view{} |
||
) |
Creates an index.
A convenience method that calls create_many.
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://docs.mongodb.com/manual/reference/method/db.collection.createIndex/. |
options | Optional arguments for the overall operation, see mongocxx::options::index_view. |
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. |
stdx::optional<std::string> mongocxx::index_view::create_one | ( | const client_session & | session, |
const bsoncxx::document::view_or_value & | keys, | ||
const bsoncxx::document::view_or_value & | index_options = {} , |
||
const options::index_view & | options = options::index_view{} |
||
) |
Creates an index.
A convenience method that calls create_many.
session | The mongocxx::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://docs.mongodb.com/manual/reference/method/db.collection.createIndex/. |
options | Optional arguments for the overall operation, see mongocxx::options::index_view. |
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. |
stdx::optional<std::string> mongocxx::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.
session | The mongocxx::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::options::index_view. |
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. |
stdx::optional<std::string> mongocxx::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.
index | Index_model describing the index being created. |
options | Optional arguments for the overall operation, see mongocxx::options::index_view. |
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. |
void mongocxx::index_view::drop_all | ( | const client_session & | session, |
const options::index_view & | options = options::index_view{} |
||
) |
Drops all indexes in the collection.
session | The mongocxx::client_session with which to perform the drop. |
options | Optional arguments for the overall operation, see mongocxx::options::index_view. |
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. |
void mongocxx::index_view::drop_all | ( | const options::index_view & | options = options::index_view{} | ) |
Drops all indexes in the collection.
options | Optional arguments for the overall operation, see mongocxx::options::index_view. |
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. |
void mongocxx::index_view::drop_one | ( | const bsoncxx::document::view_or_value & | keys, |
const bsoncxx::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.
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::options::index_view. |
Throws | bsoncxx::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 |
void mongocxx::index_view::drop_one | ( | const client_session & | session, |
const bsoncxx::document::view_or_value & | keys, | ||
const bsoncxx::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.
session | The mongocxx::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::options::index_view. |
Throws | bsoncxx::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 |
void mongocxx::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.
session | The mongocxx::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::options::index_view. |
Throws | bsoncxx::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 |
void mongocxx::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.
session | The mongocxx::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::options::index_view. |
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. |
void mongocxx::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.
index | An index model describing the index being dropped. |
options | Optional arguments for the overall operation, see mongocxx::options::index_view. |
Throws | bsoncxx::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 |
void mongocxx::index_view::drop_one | ( | stdx::string_view | name, |
const options::index_view & | options = options::index_view{} |
||
) |
Drops a single index by name.
name | The name of the index being dropped. |
options | Optional arguments for the overall operation, see mongocxx::options::index_view. |
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. |
cursor mongocxx::index_view::list | ( | const client_session & | session | ) |
Returns a cursor over all the indexes.
session | The mongocxx::client_session with which to perform the list operation. |