MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
mongocxx::v1::client Class Reference

#include <mongocxx/v1/client.hpp>

Description

A connection to a MongoDB deployment.

Important
This interface does NOT fully conform to the CMAP specification!
See also
Attention
This feature is experimental! It is not ready for use!

Classes

class  options
 Options for mongocxx::v1::client. More...

Public Types

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

Public Member Functions

 client ()
 Default initialization.
 client (client &&other) noexcept
 Move constructor.
 client (client const &other)=delete
 This class is not copyable.
 ~client ()
 Destroy this object.
v1::database database (bsoncxx::v1::stdx::string_view name)
 Access the database with the given name.
 operator bool () const
 Return true when *this is NOT in an assign-or-destroy-only state.
clientoperator= (client &&other) noexcept
 Move assignment.
clientoperator= (client const &other)=delete
 This class is not copyable.
v1::database operator[] (bsoncxx::v1::stdx::string_view name)
 Equivalent to this->database(name).
void reset ()
 Invalidate this client object without invaliding existing cursors or sessions.
v1::uri uri () const
 Return the mongocxx::v1::uri used to initialize this client.
 client (v1::uri uri, options opts)
 Initialize with the given URI.
 client (v1::uri uri)
 Initialize with the given URI.
v1::cursor list_databases ()
 Return an unsorted list of all existing databases.
v1::cursor list_databases (v1::client_session const &session)
 Return an unsorted list of all existing databases.
v1::cursor list_databases (bsoncxx::v1::document::view opts)
 Return an unsorted list of all existing databases.
v1::cursor list_databases (v1::client_session const &session, bsoncxx::v1::document::view opts)
 Return an unsorted list of all existing databases.
std::vector< std::string > list_database_names (bsoncxx::v1::document::view filter)
 Return an unsorted list of the names of all existing databases.
std::vector< std::string > list_database_names (v1::client_session const &session, bsoncxx::v1::document::view filter)
 Return an unsorted list of the names of all existing databases.
std::vector< std::string > list_database_names ()
 Return an unsorted list of the names of all existing databases.
std::vector< std::string > list_database_names (v1::client_session const &session)
 Return an unsorted list of the names of all existing databases.
v1::client_session start_session (v1::client_session::options const &opts)
 Create a new client session to use with subsequent operations.
v1::client_session start_session ()
 Create a new client session to use with subsequent operations.
v1::change_stream watch (v1::change_stream::options const &opts)
 Return a change stream subscribed to this connection.
v1::change_stream watch ()
 Return a change stream subscribed to this connection.
v1::change_stream watch (v1::client_session const &session, v1::change_stream::options const &opts)
 Return a change stream subscribed to this connection.
v1::change_stream watch (v1::client_session const &session)
 Return a change stream subscribed to this connection.
v1::change_stream watch (v1::pipeline const &pipeline, v1::change_stream::options const &opts)
 Return a change stream subscribed to this connection with events filtered/modified by pipeline.
v1::change_stream watch (v1::client_session const &session, v1::pipeline const &pipeline, v1::change_stream::options const &opts)
 Return a change stream subscribed to this connection with events filtered/modified by pipeline.
v1::change_stream watch (v1::pipeline const &pipeline)
 Return a change stream subscribed to this connection with events filtered/modified by pipeline.
v1::change_stream watch (v1::client_session const &session, v1::pipeline const &pipeline)
 Return a change stream subscribed to this connection with events filtered/modified by pipeline.

Static Public Member Functions

static std::error_category const & error_category ()
 The error category for mongocxx::v1::client::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::client::errc
strong

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

Attention
This feature is experimental! It is not ready for use!
Enumerator
zero 

Zero.

tls_not_enabled 

TLS is not enabled by URI options.

tls_not_supported 

TLS is not supported by the mongoc library.

Constructor & Destructor Documentation

◆ ~client()

mongocxx::v1::client::~client ( )

Destroy this object.

Warning
Invalidates all associated views, databases, cursors, client sessions, and change streams.

◆ client() [1/5]

mongocxx::v1::client::client ( client && other)
noexcept

Move constructor.

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

◆ client() [2/5]

mongocxx::v1::client::client ( client const & other)
delete

This class is not copyable.

◆ client() [3/5]

mongocxx::v1::client::client ( v1::uri uri,
options opts )

Initialize with the given URI.

Note
No connection is attempted until the first command executed with this client object or with an associated object obtained from this client object. Server-side errors will only be encountered during or after the first command executed.
Exceptions
mongocxx::v1::exceptionwhen a client-side error is encountered.

◆ client() [4/5]

mongocxx::v1::client::client ( v1::uri uri)

Initialize with the given URI.

Note
No connection is attempted until the first command executed with this client object or with an associated object obtained from this client object. Server-side errors will only be encountered during or after the first command executed.
Exceptions
mongocxx::v1::exceptionwhen a client-side error is encountered.

◆ client() [5/5]

mongocxx::v1::client::client ( )

Default initialization.

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

Member Function Documentation

◆ database()

v1::database mongocxx::v1::client::database ( bsoncxx::v1::stdx::string_view name)

Access the database with the given name.

◆ error_category()

std::error_category const & mongocxx::v1::client::error_category ( )
static

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

Attention
This feature is experimental! It is not ready for use!

◆ list_database_names() [1/4]

std::vector< std::string > mongocxx::v1::client::list_database_names ( )

Return an unsorted list of the names of all existing databases.

Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ list_database_names() [2/4]

std::vector< std::string > mongocxx::v1::client::list_database_names ( bsoncxx::v1::document::view filter)

Return an unsorted list of the names of all existing databases.

Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ list_database_names() [3/4]

std::vector< std::string > mongocxx::v1::client::list_database_names ( v1::client_session const & session)

Return an unsorted list of the names of all existing databases.

Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ list_database_names() [4/4]

std::vector< std::string > mongocxx::v1::client::list_database_names ( v1::client_session const & session,
bsoncxx::v1::document::view filter )

Return an unsorted list of the names of all existing databases.

Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ list_databases() [1/4]

v1::cursor mongocxx::v1::client::list_databases ( )

Return an unsorted list of all existing databases.

Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ list_databases() [2/4]

v1::cursor mongocxx::v1::client::list_databases ( bsoncxx::v1::document::view opts)

Return an unsorted list of all existing databases.

Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ list_databases() [3/4]

v1::cursor mongocxx::v1::client::list_databases ( v1::client_session const & session)

Return an unsorted list of all existing databases.

Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ list_databases() [4/4]

v1::cursor mongocxx::v1::client::list_databases ( v1::client_session const & session,
bsoncxx::v1::document::view opts )

Return an unsorted list of all existing databases.

Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ operator bool()

mongocxx::v1::client::operator bool ( ) const
explicit

Return true when *this is NOT in an assign-or-destroy-only state.

◆ operator=() [1/2]

client & mongocxx::v1::client::operator= ( client && other)
noexcept

Move assignment.

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

◆ operator=() [2/2]

client & mongocxx::v1::client::operator= ( client const & other)
delete

This class is not copyable.

◆ operator[]()

v1::database mongocxx::v1::client::operator[] ( bsoncxx::v1::stdx::string_view name)

Equivalent to this->database(name).

◆ reset()

void mongocxx::v1::client::reset ( )

Invalidate this client object without invaliding existing cursors or sessions.

Warning
Do not call this member function on a client obtained from a v1::pool.

This function must be invoked by a (forked) child process to prevent its destruction within the child process from invalidating the state of the client object within the parent process.

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

◆ start_session() [1/2]

v1::client_session mongocxx::v1::client::start_session ( )

Create a new client session to use with subsequent operations.

Important
The client session object MUST be passed as the first argument to all operations that are intended to be executed in the context of a session.
Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ start_session() [2/2]

v1::client_session mongocxx::v1::client::start_session ( v1::client_session::options const & opts)

Create a new client session to use with subsequent operations.

Important
The client session object MUST be passed as the first argument to all operations that are intended to be executed in the context of a session.
Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.
See also

◆ uri()

v1::uri mongocxx::v1::client::uri ( ) const

Return the mongocxx::v1::uri used to initialize this client.

◆ watch() [1/8]

v1::change_stream mongocxx::v1::client::watch ( )

Return a change stream subscribed to this connection.

See also

◆ watch() [2/8]

v1::change_stream mongocxx::v1::client::watch ( v1::change_stream::options const & opts)

Return a change stream subscribed to this connection.

See also

◆ watch() [3/8]

v1::change_stream mongocxx::v1::client::watch ( v1::client_session const & session)

Return a change stream subscribed to this connection.

See also

◆ watch() [4/8]

v1::change_stream mongocxx::v1::client::watch ( v1::client_session const & session,
v1::change_stream::options const & opts )

Return a change stream subscribed to this connection.

See also

◆ watch() [5/8]

v1::change_stream mongocxx::v1::client::watch ( v1::client_session const & session,
v1::pipeline const & pipeline )

Return a change stream subscribed to this connection with events filtered/modified by pipeline.

See also

◆ watch() [6/8]

v1::change_stream mongocxx::v1::client::watch ( v1::client_session const & session,
v1::pipeline const & pipeline,
v1::change_stream::options const & opts )

Return a change stream subscribed to this connection with events filtered/modified by pipeline.

See also

◆ watch() [7/8]

v1::change_stream mongocxx::v1::client::watch ( v1::pipeline const & pipeline)

Return a change stream subscribed to this connection with events filtered/modified by pipeline.

See also

◆ watch() [8/8]

v1::change_stream mongocxx::v1::client::watch ( v1::pipeline const & pipeline,
v1::change_stream::options const & opts )

Return a change stream subscribed to this connection with events filtered/modified by pipeline.

See also

◆ make_error_code

std::error_code make_error_code ( errc v)
friend

Support implicit conversion to std::error_code.

Attention
This feature is experimental! It is not ready for use!

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