Loading...
Searching...
No Matches
client.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/client-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/client.hpp> // IWYU pragma: export
#include <list> // IWYU pragma: keep: backward compatibility, to be removed.
#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
#include <string>
#include <utility>
#include <vector>
#include <mongocxx/change_stream-fwd.hpp>
#include <mongocxx/client_bulk_write-fwd.hpp> // IWYU pragma: export
#include <mongocxx/client_session-fwd.hpp>
#include <mongocxx/collection-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/cursor-fwd.hpp>
#include <mongocxx/database-fwd.hpp>
#include <mongocxx/options/auto_encryption-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/options/client_encryption-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/pipeline-fwd.hpp>
#include <mongocxx/pool-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/view_or_value.hpp>
#include <bsoncxx/string/view_or_value.hpp>
#include <mongocxx/client_session.hpp>
#include <mongocxx/database.hpp>
#include <mongocxx/options/change_stream.hpp>
#include <mongocxx/options/client.hpp>
#include <mongocxx/options/client_encryption.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/options/client_session.hpp>
#include <mongocxx/read_concern.hpp>
#include <mongocxx/read_preference.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/write_concern.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
class client {
private:
v1::client _client;
public:
client() noexcept {}
/* explicit(false) */ client(v1::client client) : _client{std::move(client)} {}
explicit operator v1::client() && {
return std::move(_client);
}
explicit operator v1::client() const& = delete;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() client(
v_noabi::uri const& mongodb_uri,
options::client const& options = options::client());
explicit operator bool() const noexcept {
return _client.operator bool();
}
MONGOCXX_DEPRECATED MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) read_concern(v_noabi::read_concern rc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) read_concern_deprecated(v_noabi::read_concern rc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::read_concern) read_concern() const;
MONGOCXX_DEPRECATED MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) read_preference(v_noabi::read_preference rp);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
read_preference_deprecated(v_noabi::read_preference rp);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::read_preference) read_preference() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::uri) uri() const;
MONGOCXX_DEPRECATED MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) write_concern(v_noabi::write_concern wc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) write_concern_deprecated(v_noabi::write_concern wc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::write_concern) write_concern() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::database)
database(bsoncxx::v_noabi::string::view_or_value name) const&;
v_noabi::database database(bsoncxx::v_noabi::string::view_or_value name) const&& = delete;
v_noabi::database operator[](bsoncxx::v_noabi::string::view_or_value name) const& {
return database(name);
}
v_noabi::database operator[](bsoncxx::v_noabi::string::view_or_value name) const&& = delete;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor) list_databases() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor) list_databases(v_noabi::client_session const& session) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
list_databases(bsoncxx::v_noabi::document::view_or_value const opts) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
list_databases(v_noabi::client_session const& session, bsoncxx::v_noabi::document::view_or_value const opts) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::vector<std::string>)
list_database_names(bsoncxx::v_noabi::document::view_or_value const filter = {}) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::vector<std::string>)
list_database_names(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value const filter = {}) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::client_session)
start_session(v_noabi::options::client_session const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream) watch(
v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(v_noabi::client_session const& session, v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(v_noabi::pipeline const& pipe, v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(
v_noabi::client_session const& session,
v_noabi::pipeline const& pipe,
v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::client_bulk_write) create_bulk_write();
MONGOCXX_ABI_EXPORT_CDECL(v1::client_bulk_write) create_bulk_write(v_noabi::client_session& session);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) reset();
class internal;
private:
v_noabi::change_stream _watch(
v_noabi::client_session const* session,
v_noabi::pipeline const& pipe,
v_noabi::options::change_stream const& options);
};
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::client from_v1(v1::client v) {
return {std::move(v)};
}
inline v1::client to_v1(v_noabi::client v) {
return v1::client{std::move(v)};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
auto_encryption-fwd.hpp
Declares mongocxx::v_noabi::options::auto_encryption.
bsoncxx::v_noabi::string::view_or_value
A view-or-value variant type for strings.
Definition view_or_value.hpp:41
mongocxx::client::client
client() noexcept
Default constructs a new client. The client is not connected and is equivalent to the state of a move...
Definition client.hpp:87
mongocxx::v1::client_bulk_write
A list of bulk write operations. Unlike mongocxx::v1::bulk_write, this supports writes across more th...
Definition client_bulk_write.hpp:58
mongocxx::v1::client
A connection to a MongoDB deployment.
Definition client.hpp:60
mongocxx::v_noabi::change_stream
A MongoDB change stream.
Definition change_stream.hpp:44
mongocxx::v_noabi::client_session
Supports MongoDB client session operations.
Definition client_session.hpp:58
mongocxx::v_noabi::client
A client connection to a MongoDB server.
Definition client.hpp:77
mongocxx::v_noabi::client::read_preference
v_noabi::read_preference read_preference() const
Returns the current read preference for this client.
mongocxx::v_noabi::client::list_databases
v_noabi::cursor list_databases() const
Enumerates the databases in the client.
mongocxx::v_noabi::client::read_preference
void read_preference(v_noabi::read_preference rp)
Sets the read preference for this client.
mongocxx::v_noabi::client::write_concern
v_noabi::write_concern write_concern() const
Returns the current write concern for this client.
mongocxx::v_noabi::client::list_database_names
std::vector< std::string > list_database_names(bsoncxx::v_noabi::document::view_or_value const filter={}) const
Queries the MongoDB server for a list of known databases.
mongocxx::v_noabi::client::watch
v_noabi::change_stream watch(v_noabi::options::change_stream const &options={})
Get a change stream on this client with an empty pipeline.
mongocxx::v_noabi::client::list_databases
v_noabi::cursor list_databases(v_noabi::client_session const &session) const
Enumerates the databases in the client.
mongocxx::v_noabi::client::create_bulk_write
v1::client_bulk_write create_bulk_write()
Return a new client-level bulk write operation for use with this client.
mongocxx::v_noabi::client::uri
v_noabi::uri uri() const
Returns the current uri for this client.
mongocxx::v_noabi::client::client
client() noexcept
Default constructs a new client. The client is not connected and is equivalent to the state of a move...
Definition client.hpp:87
mongocxx::v_noabi::client::operator[]
v_noabi::database operator[](bsoncxx::v_noabi::string::view_or_value name) const &
Allows the syntax client["db_name"] as a convenient shorthand for the client::database() method by im...
Definition client.hpp:251
mongocxx::v_noabi::client::create_bulk_write
v1::client_bulk_write create_bulk_write(v_noabi::client_session &session)
Return a new client-level bulk write operation for use with this client.
mongocxx::v_noabi::client::read_concern
void read_concern(v_noabi::read_concern rc)
Sets the read concern for this client.
mongocxx::v_noabi::client::write_concern
void write_concern(v_noabi::write_concern wc)
Sets the write concern for this client.
mongocxx::v_noabi::client::read_concern
v_noabi::read_concern read_concern() const
Returns the current read concern for this client.
mongocxx::v_noabi::client::client
client(v1::client client)
Construct with the mongocxx::v1 equivalent.
Definition client.hpp:92
mongocxx::v_noabi::client::database
v_noabi::database database(bsoncxx::v_noabi::string::view_or_value name) const &
Obtains a database that represents a logical grouping of collections on a MongoDB server.
mongocxx::v_noabi::client::start_session
v_noabi::client_session start_session(v_noabi::options::client_session const &options={})
Create a client session for a sequence of operations.
mongocxx::v_noabi::client::reset
void reset()
Prevents resource cleanup in the child process from interfering with the parent process after forking...
mongocxx::v_noabi::cursor
A cursor over the documents returned by a query to a MongoDB server.
Definition cursor.hpp:50
mongocxx::v_noabi::database
A MongoDB database.
Definition database.hpp:63
mongocxx::v_noabi::options::change_stream
Used by change streams.
Definition change_stream.hpp:52
mongocxx::v_noabi::pipeline
A MongoDB aggregation pipeline.
Definition pipeline.hpp:45
mongocxx::v_noabi::read_concern
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
mongocxx::v_noabi::read_preference
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:59
mongocxx::v_noabi::uri
A MongoDB connection string URI.
Definition uri.hpp:55
mongocxx::v_noabi::write_concern
The level of acknowledgment requested for write operations to a MongoDB server.
Definition write_concern.hpp:54
view_or_value.hpp
Provides bsoncxx::v_noabi::document::view_or_value.
MONGOCXX_DEPRECATED
#define MONGOCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition export.hpp:25
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
view_or_value.hpp
Provides bsoncxx::v_noabi::string::view_or_value.
client.hpp
Provides mongocxx::v1::client.
change_stream-fwd.hpp
Declares mongocxx::v_noabi::change_stream.
client-fwd.hpp
Declares mongocxx::v_noabi::client.
client_bulk_write-fwd.hpp
Declares mongocxx::client_bulk_write.
client_session-fwd.hpp
Declares mongocxx::v_noabi::client_session.
client_session.hpp
Provides mongocxx::v_noabi::client_session.
collection-fwd.hpp
Declares mongocxx::v_noabi::collection.
cursor-fwd.hpp
Declares mongocxx::v_noabi::cursor.
database-fwd.hpp
Declares mongocxx::v_noabi::database.
database.hpp
Provides mongocxx::v_noabi::database.
change_stream.hpp
Provides mongocxx::v_noabi::options::change_stream.
client.hpp
Provides mongocxx::v_noabi::options::client.
client_encryption-fwd.hpp
Declares mongocxx::v_noabi::options::client_encryption.
client_encryption.hpp
Provides mongocxx::v_noabi::options::client_encryption.
client_session.hpp
Provides mongocxx::v_noabi::options::client_session.
pipeline-fwd.hpp
Declares mongocxx::v_noabi::pipeline.
pool-fwd.hpp
Declares mongocxx::v_noabi::pool.
read_concern.hpp
Provides mongocxx::v_noabi::read_concern.
read_preference.hpp
Provides mongocxx::v_noabi::read_preference.
uri.hpp
Provides mongocxx::v_noabi::uri.
write_concern.hpp
Provides mongocxx::v_noabi::write_concern.