MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
client.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <memory>
18#include <string>
19
26#include <mongocxx/pool-fwd.hpp>
27
29#include <mongocxx/database.hpp>
35#include <mongocxx/stdx.hpp>
36#include <mongocxx/uri.hpp>
38
40
41namespace mongocxx {
42namespace v_noabi {
43
62class client {
63 public:
70
83 client(const mongocxx::v_noabi::uri& mongodb_uri,
84 const options::client& options = options::client());
85
90
94 MONGOCXX_ABI_EXPORT_CDECL(client&) operator=(client&&) noexcept;
95
100
101 client(const client&) = delete;
102 client& operator=(const client&) = delete;
103
108 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const noexcept;
109
129
130 MONGOCXX_ABI_EXPORT_CDECL(void) read_concern_deprecated(mongocxx::v_noabi::read_concern rc);
131
138
158
160 read_preference_deprecated(mongocxx::v_noabi::read_preference rp);
161
171
178
195
196 MONGOCXX_ABI_EXPORT_CDECL(void) write_concern_deprecated(mongocxx::v_noabi::write_concern wc);
197
203
215 database(bsoncxx::v_noabi::string::view_or_value name) const&;
216
217 mongocxx::v_noabi::database database(bsoncxx::v_noabi::string::view_or_value name) const&& =
218 delete;
219
231 mongocxx::v_noabi::database operator[](bsoncxx::v_noabi::string::view_or_value name) const& {
232 return database(name);
233 }
234
236 delete;
253
273
293 list_databases(const bsoncxx::v_noabi::document::view_or_value opts) const;
294
318 const bsoncxx::v_noabi::document::view_or_value opts) const;
319
334 MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>)
335 list_database_names(const bsoncxx::v_noabi::document::view_or_value filter = {}) const;
336
354 MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>)
356 const bsoncxx::v_noabi::document::view_or_value filter = {}) const;
357
369 start_session(const options::client_session& options = {});
370
386
404 watch(const client_session& session, const options::change_stream& options = {});
405
425 watch(const pipeline& pipe, const options::change_stream& options = {});
426
446 watch(const client_session& session,
447 const pipeline& pipe,
448 const options::change_stream& options = {});
449
466
467 private:
468 friend ::mongocxx::v_noabi::client_session;
469 friend ::mongocxx::v_noabi::collection;
470 friend ::mongocxx::v_noabi::database;
471 friend ::mongocxx::v_noabi::options::auto_encryption;
472 friend ::mongocxx::v_noabi::options::client_encryption;
473 friend ::mongocxx::v_noabi::pool;
474
475 explicit client(void* implementation);
476
477 change_stream _watch(const client_session* session,
478 const pipeline& pipe,
479 const options::change_stream& options);
480
481 class impl;
482
483 impl& _get_impl();
484 const impl& _get_impl() const;
485
486 std::unique_ptr<impl> _impl;
487};
488
489} // namespace v_noabi
490} // namespace mongocxx
491
493
Declares mongocxx::v_noabi::options::auto_encryption.
Class representing a view-or-value variant type for strings.
Definition view_or_value.hpp:41
Class representing a MongoDB change stream.
Definition change_stream.hpp:35
Use a session for a sequence of operations, optionally with either causal consistency or snapshots.
Definition client_session.hpp:48
Class representing a client connection to MongoDB.
Definition client.hpp:62
client_session start_session(const options::client_session &options={})
Create a client session for a sequence of operations.
std::vector< std::string > list_database_names(const bsoncxx::v_noabi::document::view_or_value filter={}) const
Queries the MongoDB server for a list of known databases.
change_stream watch(const options::change_stream &options={})
Get a change stream on this client with an empty pipeline.
mongocxx::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:231
cursor list_databases(const client_session &session) const
Enumerates the databases in the client.
client() noexcept
Default constructs a new client. The client is not connected and is equivalent to the state of a move...
cursor list_databases() const
Enumerates the databases in the client.
void reset()
Prevents resource cleanup in the child process from interfering with the parent process after forking...
mongocxx::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.
Class representing a pointer to the result set of a query on a MongoDB server.
Definition cursor.hpp:42
Class representing a MongoDB database.
Definition database.hpp:47
Class representing MongoDB change stream options.
Definition change_stream.hpp:40
Class representing a MongoDB aggregation pipeline.
Definition pipeline.hpp:39
A class to represent the read concern. Read concern can be set at the client, database,...
Definition read_concern.hpp:58
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition read_preference.hpp:65
Class representing a MongoDB connection string URI.
Definition uri.hpp:43
Class representing the server-side requirement for reporting the success of a write operation....
Definition write_concern.hpp:61
Declares mongocxx::v_noabi::client.
Declares mongocxx::v_noabi::client_session.
Provides mongocxx::v_noabi::client_session.
Declares mongocxx::v_noabi::collection.
Declares mongocxx::v_noabi::database.
Provides mongocxx::v_noabi::database.
#define MONGOCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition fwd.hpp:258
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:222
The mongocxx macro guard postlude header.
The mongocxx macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace within which all mongocxx library entities are declared.
The top-level namespace reserved for the C++ standard library.
Provides mongocxx::v_noabi::options::client.
Declares mongocxx::v_noabi::options::client_encryption.
Provides mongocxx::v_noabi::options::client_encryption.
Provides mongocxx::v_noabi::options::client_session.
Declares mongocxx::v_noabi::pool.
Provides mongocxx::v_noabi::read_concern.
Provides mongocxx::v_noabi::read_preference.
Redeclares bsoncxx::v_noabi::stdx in mongocxx::v_noabi::stdx for internal use.
Provides mongocxx::v_noabi::uri.
Provides mongocxx::v_noabi::write_concern.