MongoDB C++ Driver mongocxx-4.0.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/uri.hpp>
37
39
40namespace mongocxx {
41namespace v_noabi {
42
61class client {
62 public:
69
82 client(const mongocxx::v_noabi::uri& mongodb_uri,
83 const options::client& options = options::client());
84
89
93 MONGOCXX_ABI_EXPORT_CDECL(client&) operator=(client&&) noexcept;
94
99
100 client(const client&) = delete;
101 client& operator=(const client&) = delete;
102
107 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const noexcept;
108
128
129 MONGOCXX_ABI_EXPORT_CDECL(void) read_concern_deprecated(mongocxx::v_noabi::read_concern rc);
130
137
157
159 read_preference_deprecated(mongocxx::v_noabi::read_preference rp);
160
170
177
194
195 MONGOCXX_ABI_EXPORT_CDECL(void) write_concern_deprecated(mongocxx::v_noabi::write_concern wc);
196
202
214 database(bsoncxx::v_noabi::string::view_or_value name) const&;
215
216 mongocxx::v_noabi::database database(bsoncxx::v_noabi::string::view_or_value name) const&& =
217 delete;
218
230 mongocxx::v_noabi::database operator[](bsoncxx::v_noabi::string::view_or_value name) const& {
231 return database(name);
232 }
233
235 delete;
252
272
292 list_databases(const bsoncxx::v_noabi::document::view_or_value opts) const;
293
317 const bsoncxx::v_noabi::document::view_or_value opts) const;
318
333 MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>)
334 list_database_names(const bsoncxx::v_noabi::document::view_or_value filter = {}) const;
335
353 MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>)
355 const bsoncxx::v_noabi::document::view_or_value filter = {}) const;
356
368 start_session(const options::client_session& options = {});
369
385
403 watch(const client_session& session, const options::change_stream& options = {});
404
424 watch(const pipeline& pipe, const options::change_stream& options = {});
425
445 watch(const client_session& session,
446 const pipeline& pipe,
447 const options::change_stream& options = {});
448
465
466 private:
467 friend ::mongocxx::v_noabi::client_session;
468 friend ::mongocxx::v_noabi::collection;
469 friend ::mongocxx::v_noabi::database;
470 friend ::mongocxx::v_noabi::options::auto_encryption;
471 friend ::mongocxx::v_noabi::options::client_encryption;
472 friend ::mongocxx::v_noabi::pool;
473
474 explicit client(void* implementation);
475
476 change_stream _watch(const client_session* session,
477 const pipeline& pipe,
478 const options::change_stream& options);
479
480 class impl;
481
482 impl& _get_impl();
483 const impl& _get_impl() const;
484
485 std::unique_ptr<impl> _impl;
486};
487
488} // namespace v_noabi
489} // namespace mongocxx
490
492
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:61
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:230
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:46
Class representing MongoDB change stream options.
Definition change_stream.hpp:38
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:57
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition read_preference.hpp:64
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:60
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:212
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:204
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.
Provides mongocxx::v_noabi::uri.
Provides mongocxx::v_noabi::write_concern.