|
MongoDB C++ Driver
mongocxx-3.10.2
|
Class representing a MongoDB database. More...
#include <database.hpp>
Public Member Functions | |
| database () noexcept | |
| Default constructs a new database. More... | |
| database (database &&) noexcept | |
| Move constructs a database. | |
| database & | operator= (database &&) noexcept |
| Move assigns a database. | |
| database (const database &) | |
| Copy constructs a database. | |
| database & | operator= (const database &) |
| Copy assigns a database. | |
| ~database () | |
| Destroys a database. | |
| operator bool () const noexcept | |
| Returns true if the client is valid, meaning it was not default constructed or moved from. | |
| bool | has_collection (bsoncxx::v_noabi::string::view_or_value name) const |
| Checks whether this database contains a collection having the given name. More... | |
| stdx::string_view | name () const |
| Get the name of this database. More... | |
| void | read_concern (mongocxx::v_noabi::read_concern rc) |
| Sets the read_concern for this database. More... | |
| mongocxx::v_noabi::read_concern | read_concern () const |
| The current read concern for this database. More... | |
| void | read_preference (mongocxx::v_noabi::read_preference rp) |
| Sets the read_preference for this database. More... | |
| mongocxx::v_noabi::read_preference | read_preference () const |
| The current read preference for this database. More... | |
| void | write_concern (mongocxx::v_noabi::write_concern wc) |
| Sets the write_concern for this database. More... | |
| mongocxx::v_noabi::write_concern | write_concern () const |
| The current write_concern for this database. More... | |
| mongocxx::v_noabi::collection | collection (bsoncxx::v_noabi::string::view_or_value name) const |
| Access a collection (logical grouping of documents) within this database. More... | |
| mongocxx::v_noabi::collection | operator[] (bsoncxx::v_noabi::string::view_or_value name) const |
| Allows the db["collection_name"] syntax to be used to access a collection within this database. More... | |
| gridfs::bucket | gridfs_bucket (const options::gridfs::bucket &options=options::gridfs::bucket()) const |
| Access a GridFS bucket within this database. More... | |
| cursor | aggregate (const pipeline &pipeline, const options::aggregate &options=options::aggregate()) |
| Runs an aggregation framework pipeline against this database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions. More... | |
| cursor | aggregate (const client_session &session, const pipeline &pipeline, const options::aggregate &options=options::aggregate()) |
| Runs an aggregation framework pipeline against this database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions. More... | |
| bsoncxx::v_noabi::document::value | run_command (bsoncxx::v_noabi::document::view_or_value command) |
| Runs a command against this database. More... | |
| bsoncxx::v_noabi::document::value | run_command (const client_session &session, bsoncxx::v_noabi::document::view_or_value command) |
| Runs a command against this database. More... | |
| bsoncxx::v_noabi::document::value | run_command (bsoncxx::v_noabi::document::view_or_value command, uint32_t server_id) |
| Executes a command on a specific server using this database. More... | |
| mongocxx::v_noabi::collection | create_collection (stdx::string_view name, bsoncxx::v_noabi::document::view_or_value collection_options={}, const stdx::optional< write_concern > &write_concern={}) |
| Explicitly creates a collection in this database with the specified options. More... | |
| mongocxx::v_noabi::collection | create_collection (const client_session &session, stdx::string_view name, bsoncxx::v_noabi::document::view_or_value collection_options={}, const stdx::optional< write_concern > &write_concern={}) |
| Explicitly creates a collection in this database with the specified options. More... | |
| mongocxx::v_noabi::collection | create_collection (bsoncxx::v_noabi::string::view_or_value name, const options::create_collection_deprecated &collection_options, const stdx::optional< write_concern > &write_concern={}) |
| Explicitly creates a collection in this database with the specified options. More... | |
| mongocxx::v_noabi::collection | create_collection_deprecated (bsoncxx::v_noabi::string::view_or_value name, const options::create_collection_deprecated &collection_options, const stdx::optional< write_concern > &write_concern={}) |
| Explicitly creates a collection in this database with the specified options. More... | |
| mongocxx::v_noabi::collection | create_collection (const client_session &session, bsoncxx::v_noabi::string::view_or_value name, const options::create_collection_deprecated &collection_options, const stdx::optional< write_concern > &write_concern={}) |
| Explicitly creates a collection in this database with the specified options. More... | |
| mongocxx::v_noabi::collection | create_collection_deprecated (const client_session &session, bsoncxx::v_noabi::string::view_or_value name, const options::create_collection_deprecated &collection_options, const stdx::optional< write_concern > &write_concern={}) |
| Explicitly creates a collection in this database with the specified options. More... | |
| void | drop (const bsoncxx::v_noabi::stdx::optional< mongocxx::v_noabi::write_concern > &write_concern={}) |
| Drops the database and all its collections. More... | |
| void | drop (const client_session &session, const bsoncxx::v_noabi::stdx::optional< mongocxx::v_noabi::write_concern > &write_concern={}) |
| Drops the database and all its collections. More... | |
| cursor | list_collections (bsoncxx::v_noabi::document::view_or_value filter={}) |
| Enumerates the collections in this database. More... | |
| cursor | list_collections (const client_session &session, bsoncxx::v_noabi::document::view_or_value filter={}) |
| Enumerates the collections in this database. More... | |
| std::vector< std::string > | list_collection_names (bsoncxx::v_noabi::document::view_or_value filter={}) |
| Enumerates the collection names in this database. More... | |
| std::vector< std::string > | list_collection_names (const client_session &session, bsoncxx::v_noabi::document::view_or_value filter={}) |
| Enumerates the collection names in this database. More... | |
| change_stream | watch (const options::change_stream &options={}) |
| Gets a change stream on this database with an empty pipeline. More... | |
| change_stream | watch (const client_session &session, const options::change_stream &options={}) |
| change_stream | watch (const pipeline &pipe, const options::change_stream &options={}) |
| Gets a change stream on this database. More... | |
| change_stream | watch (const client_session &session, const pipeline &pipe, const options::change_stream &options={}) |
| Gets a change stream on this database. More... | |
Class representing a MongoDB database.
Acts as a gateway for accessing collections that are contained within a database. It inherits all of its default settings from the client that creates it.
|
noexcept |
Default constructs a new database.
The database is not valid for use and is equivalent to the state of a moved-from database. The only valid actions to take with a default constructed database are to assign to it, or destroy it.
| cursor mongocxx::v_noabi::database::aggregate | ( | const client_session & | session, |
| const pipeline & | pipeline, | ||
| const options::aggregate & | options = options::aggregate() |
||
| ) |
Runs an aggregation framework pipeline against this database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
| session | The mongocxx::v_noabi::client_session with which to perform the aggregation. |
| pipeline | The pipeline of aggregation operations to perform. |
| options | Optional arguments, see mongocxx::v_noabi::options::aggregate. |
| cursor mongocxx::v_noabi::database::aggregate | ( | const pipeline & | pipeline, |
| const options::aggregate & | options = options::aggregate() |
||
| ) |
Runs an aggregation framework pipeline against this database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
| pipeline | The pipeline of aggregation operations to perform. |
| options | Optional arguments, see mongocxx::v_noabi::options::aggregate. |
| mongocxx::v_noabi::collection mongocxx::v_noabi::database::collection | ( | bsoncxx::v_noabi::string::view_or_value | name | ) | const |
Access a collection (logical grouping of documents) within this database.
| name | the name of the collection to get. |
|
inline |
Explicitly creates a collection in this database with the specified options.
| name | the new collection's name. |
| collection_options | the options for the new collection. |
| write_concern | the write concern to use for this operation. Will default to database set write concern if none passed here. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
|
inline |
Explicitly creates a collection in this database with the specified options.
| session | The mongocxx::v_noabi::client_session with which to perform the create operation. |
| name | the new collection's name. |
| collection_options | the options for the new collection. |
| write_concern | the write concern to use for this operation. Will default to database set write concern if none passed here. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| mongocxx::v_noabi::collection mongocxx::v_noabi::database::create_collection | ( | const client_session & | session, |
| stdx::string_view | name, | ||
| bsoncxx::v_noabi::document::view_or_value | collection_options = {}, |
||
| const stdx::optional< write_concern > & | write_concern = {} |
||
| ) |
Explicitly creates a collection in this database with the specified options.
| session | The mongocxx::v_noabi::client_session with which to perform the create operation. |
| name | the new collection's name. |
| collection_options | the options for the new collection. |
| write_concern | the write concern to use for this operation. Will default to database set write concern if none passed here. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| mongocxx::v_noabi::collection mongocxx::v_noabi::database::create_collection | ( | stdx::string_view | name, |
| bsoncxx::v_noabi::document::view_or_value | collection_options = {}, |
||
| const stdx::optional< write_concern > & | write_concern = {} |
||
| ) |
Explicitly creates a collection in this database with the specified options.
| name | the new collection's name. |
| collection_options | the options for the new collection. |
| write_concern | the write concern to use for this operation. Will default to database set write concern if none passed here. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| mongocxx::v_noabi::collection mongocxx::v_noabi::database::create_collection_deprecated | ( | bsoncxx::v_noabi::string::view_or_value | name, |
| const options::create_collection_deprecated & | collection_options, | ||
| const stdx::optional< write_concern > & | write_concern = {} |
||
| ) |
Explicitly creates a collection in this database with the specified options.
| name | the new collection's name. |
| collection_options | the options for the new collection. |
| write_concern | the write concern to use for this operation. Will default to database set write concern if none passed here. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| mongocxx::v_noabi::collection mongocxx::v_noabi::database::create_collection_deprecated | ( | const client_session & | session, |
| bsoncxx::v_noabi::string::view_or_value | name, | ||
| const options::create_collection_deprecated & | collection_options, | ||
| const stdx::optional< write_concern > & | write_concern = {} |
||
| ) |
Explicitly creates a collection in this database with the specified options.
| session | The mongocxx::v_noabi::client_session with which to perform the create operation. |
| name | the new collection's name. |
| collection_options | the options for the new collection. |
| write_concern | the write concern to use for this operation. Will default to database set write concern if none passed here. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| void mongocxx::v_noabi::database::drop | ( | const bsoncxx::v_noabi::stdx::optional< mongocxx::v_noabi::write_concern > & | write_concern = {} | ) |
Drops the database and all its collections.
| write_concern | (optional) The write concern to be used for this operation. If not passed here, the write concern set on the database will be used. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| void mongocxx::v_noabi::database::drop | ( | const client_session & | session, |
| const bsoncxx::v_noabi::stdx::optional< mongocxx::v_noabi::write_concern > & | write_concern = {} |
||
| ) |
Drops the database and all its collections.
| session | The mongocxx::v_noabi::client_session with which to perform the aggregation. |
| write_concern | (optional) The write concern to be used for this operation. If not passed here, the write concern set on the database will be used. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| gridfs::bucket mongocxx::v_noabi::database::gridfs_bucket | ( | const options::gridfs::bucket & | options = options::gridfs::bucket() | ) | const |
Access a GridFS bucket within this database.
| options | The options for the bucket. |
gridfs::bucket for more information about GridFS.| mongocxx::v_noabi::logic_error | if options are invalid. |
| bool mongocxx::v_noabi::database::has_collection | ( | bsoncxx::v_noabi::string::view_or_value | name | ) | const |
Checks whether this database contains a collection having the given name.
| name | the name of the collection. |
| mongocxx::v_noabi::operation_exception | if the underlying 'listCollections' command fails. |
| std::vector<std::string> mongocxx::v_noabi::database::list_collection_names | ( | bsoncxx::v_noabi::document::view_or_value | filter = {} | ) |
Enumerates the collection names in this database.
| filter | An optional query expression to filter the returned collection names. |
| mongocxx::v_noabi::operation_exception | if the underlying 'listCollections' command fails. |
| std::vector<std::string> mongocxx::v_noabi::database::list_collection_names | ( | const client_session & | session, |
| bsoncxx::v_noabi::document::view_or_value | filter = {} |
||
| ) |
Enumerates the collection names in this database.
| session | The mongocxx::v_noabi::client_session with which to perform the aggregation. |
| filter | An optional query expression to filter the returned collection names. |
| mongocxx::v_noabi::operation_exception | if the underlying 'listCollections' command fails. |
| cursor mongocxx::v_noabi::database::list_collections | ( | bsoncxx::v_noabi::document::view_or_value | filter = {} | ) |
Enumerates the collections in this database.
| filter | An optional query expression to filter the returned collections. |
| cursor mongocxx::v_noabi::database::list_collections | ( | const client_session & | session, |
| bsoncxx::v_noabi::document::view_or_value | filter = {} |
||
| ) |
Enumerates the collections in this database.
| session | The mongocxx::v_noabi::client_session with which to perform the aggregation. |
| filter | An optional query expression to filter the returned collections. |
| stdx::string_view mongocxx::v_noabi::database::name | ( | ) | const |
Get the name of this database.
| mongocxx::v_noabi::collection mongocxx::v_noabi::database::operator[] | ( | bsoncxx::v_noabi::string::view_or_value | name | ) | const |
Allows the db["collection_name"] syntax to be used to access a collection within this database.
| name | the name of the collection to get. |
| mongocxx::v_noabi::read_concern mongocxx::v_noabi::database::read_concern | ( | ) | const |
The current read concern for this database.
If the read_concern is not explicitly set on this database object, it inherits the read_concern from its parent client object.
| void mongocxx::v_noabi::database::read_concern | ( | mongocxx::v_noabi::read_concern | rc | ) |
Sets the read_concern for this database.
| rc | The new read_concern |
| mongocxx::v_noabi::read_preference mongocxx::v_noabi::database::read_preference | ( | ) | const |
The current read preference for this database.
| void mongocxx::v_noabi::database::read_preference | ( | mongocxx::v_noabi::read_preference | rp | ) |
Sets the read_preference for this database.
| rp | the new read_preference. |
| bsoncxx::v_noabi::document::value mongocxx::v_noabi::database::run_command | ( | bsoncxx::v_noabi::document::view_or_value | command | ) |
Runs a command against this database.
| command | document representing the command to be run. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| bsoncxx::v_noabi::document::value mongocxx::v_noabi::database::run_command | ( | bsoncxx::v_noabi::document::view_or_value | command, |
| uint32_t | server_id | ||
| ) |
Executes a command on a specific server using this database.
| command | document representing the command to be run. |
| server_id | specifying which server to use. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| bsoncxx::v_noabi::document::value mongocxx::v_noabi::database::run_command | ( | const client_session & | session, |
| bsoncxx::v_noabi::document::view_or_value | command | ||
| ) |
Runs a command against this database.
| session | The mongocxx::v_noabi::client_session with which to run the command. |
| command | document representing the command to be run. |
| mongocxx::v_noabi::operation_exception | if the operation fails. |
| change_stream mongocxx::v_noabi::database::watch | ( | const client_session & | session, |
| const options::change_stream & | options = {} |
||
| ) |
| session | The mongocxx::v_noabi::client_session with which to perform the watch operation. |
| options | The options to use when creating the change stream. |
| change_stream mongocxx::v_noabi::database::watch | ( | const client_session & | session, |
| const pipeline & | pipe, | ||
| const options::change_stream & | options = {} |
||
| ) |
Gets a change stream on this database.
| session | The mongocxx::v_noabi::client_session with which to perform the watch operation. |
| pipe | The aggregation pipeline to be used on the change notifications. |
| options | The options to use when creating the change stream. |
| change_stream mongocxx::v_noabi::database::watch | ( | const options::change_stream & | options = {} | ) |
Gets a change stream on this database with an empty pipeline.
Change streams are only supported with a "majority" read concern or no read concern.
| options | The options to use when creating the change stream. |
| change_stream mongocxx::v_noabi::database::watch | ( | const pipeline & | pipe, |
| const options::change_stream & | options = {} |
||
| ) |
Gets a change stream on this database.
Change streams are only supported with a "majority" read concern or no read concern.
| pipe | The aggregation pipeline to be used on the change notifications. Only a subset of pipeline operations are supported for change streams. For more information see the change streams documentation. |
| options | The options to use when creating the change stream. |
| mongocxx::v_noabi::write_concern mongocxx::v_noabi::database::write_concern | ( | ) | const |
The current write_concern for this database.
| void mongocxx::v_noabi::database::write_concern | ( | mongocxx::v_noabi::write_concern | wc | ) |
Sets the write_concern for this database.