MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
database.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 <mongocxx/v1/database-fwd.hpp> // IWYU pragma: export
18
19//
20
22
24
31
35
41
42#include <cstdint>
43#include <string>
44#include <vector>
45
46namespace mongocxx {
47namespace v1 {
48
57class database {
58 private:
59 class impl;
60 void* _impl;
61
62 public:
69
77
84 MONGOCXX_ABI_EXPORT_CDECL(database&) operator=(database&& other) noexcept;
85
90
94 MONGOCXX_ABI_EXPORT_CDECL(database&) operator=(database const& other);
95
103
107 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
108
117 v1::pipeline const& pipeline,
118 v1::aggregate_options const& opts = {});
119
121 aggregate(v1::client_session const& session, v1::pipeline const& pipeline, v1::aggregate_options const& opts = {});
124
138
140 v1::client_session const& session,
144
158 std::uint32_t server_id);
159
174
176 v1::client_session const& session,
182
194
196 v1::client_session const& session,
200
208
220
222 v1::client_session const& session,
223 bsoncxx::v1::document::view filter = {});
226
238
240 v1::client_session const& session,
241 bsoncxx::v1::document::view filter = {});
244
249
259
264
274
279
289
294
299
304
315
324
326 v1::client_session const& session,
327 v1::change_stream::options const& opts = {});
330
339 v1::pipeline const& pipeline,
340 v1::change_stream::options const& opts = {});
341
343 watch(v1::client_session const& session, v1::pipeline const& pipeline, v1::change_stream::options const& opts = {});
346
347 class internal;
348
349 private:
350 /* explicit(false) */ database(void* impl);
351};
352
353} // namespace v1
354} // namespace mongocxx
355
357
Provides mongocxx::v1::aggregate_options.
A BSON document.
Definition value.hpp:46
A non-owning, read-only BSON document.
Definition view.hpp:54
A polyfill for std::optional<T>.
Definition optional.hpp:799
A polyfill for std::string_view.
Definition string_view.hpp:412
Options for an "aggregate" command.
Definition aggregate_options.hpp:64
Options for mongocxx::v1::change_stream.
Definition change_stream.hpp:174
A MongoDB change stream.
Definition change_stream.hpp:50
A MongoDB client session.
Definition client_session.hpp:48
A MongoDB collection.
Definition collection.hpp:83
A MongoDB cursor.
Definition cursor.hpp:41
~database()
Destroy this object.
v1::collection create_collection(v1::client_session const &session, bsoncxx::v1::stdx::string_view name, bsoncxx::v1::document::view opts={}, bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={})
Explicitly create a new collection or view in this database.
v1::collection collection(bsoncxx::v1::stdx::string_view name) const
Access the collection with the given name.
v1::change_stream watch(v1::pipeline const &pipeline, v1::change_stream::options const &opts={})
Return a change stream subscribed to this collection with events filtered/modified by pipeline.
v1::change_stream watch(v1::client_session const &session, v1::change_stream::options const &opts={})
Return a change stream subscribed to this database.
v1::change_stream watch(v1::change_stream::options const &opts={})
Return a change stream subscribed to this database.
std::vector< std::string > list_collection_names(bsoncxx::v1::document::view filter={})
Return an unsorted list of the names of all the collections and views in this database.
v1::write_concern write_concern() const
Return the current default "writeConcern" to use for operations on this database.
v1::cursor list_collections(bsoncxx::v1::document::view filter={})
Return an unsorted list of all collections and views in this database.
bsoncxx::v1::document::value run_command(v1::client_session const &session, bsoncxx::v1::document::view command)
Run an arbitrary database command.
v1::read_concern read_concern() const
Return the current default "readConcern" to use for operations on this database.
bsoncxx::v1::document::value run_command(bsoncxx::v1::document::view command, std::uint32_t server_id)
Run an arbitrary database command against the requested specific server.
database()
Default initialization.
bsoncxx::v1::stdx::string_view name() const
Return the name of this database.
v1::cursor aggregate(v1::pipeline const &pipeline, v1::aggregate_options const &opts={})
Run an aggregation framework pipeline.
void write_concern(v1::write_concern const &wc)
Set the default "writeConcern" to use for operations on this database.
void read_preference(v1::read_preference const &rp)
Set the default "readPreference" to use for operations on this database.
bsoncxx::v1::document::value run_command(bsoncxx::v1::document::view command)
Run an arbitrary database command.
v1::gridfs::bucket gridfs_bucket(v1::gridfs::bucket::options const &opts={}) const
Return a GridFS bucket for this database.
void read_concern(v1::read_concern const &rc)
Set the default "readConcern" to use for operations on this database.
void drop(v1::client_session const &session, bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={})
Drop this database and all associated data files.
std::vector< std::string > list_collection_names(v1::client_session const &session, bsoncxx::v1::document::view filter={})
Return an unsorted list of the names of all the collections and views in this database.
database(database &&other) noexcept
Move constructor.
v1::cursor list_collections(v1::client_session const &session, bsoncxx::v1::document::view filter={})
Return an unsorted list of all collections and views in this database.
bool has_collection(bsoncxx::v1::stdx::string_view name)
Return true when this database contains a collection with the given name.
v1::read_preference read_preference() const
Return the current default "readPreference" to use for operations on this database.
v1::collection create_collection(bsoncxx::v1::stdx::string_view name, bsoncxx::v1::document::view opts={}, bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={})
Explicitly create a new collection or view in this database.
void drop(bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={})
Drop this database and all associated data files.
v1::collection operator[](bsoncxx::v1::stdx::string_view name) const
Equivalent to this->collection(name).
Options for mongocxx::v1::gridfs::bucket.
Definition bucket.hpp:345
A GridFS bucket.
Definition bucket.hpp:62
A MongoDB aggregation pipeline.
Definition pipeline.hpp:43
Options related to a MongoDB Read Concern.
Definition read_concern.hpp:44
Options related to a MongoDB Read Preference.
Definition read_preference.hpp:49
Options related to a MongoDB Write Concern.
Definition write_concern.hpp:49
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v1::change_stream.
Declares mongocxx::v1::client_session.
Declares mongocxx::v1::collection.
Declares mongocxx::v1::cursor.
Declares mongocxx::v1::database.
Declares bsoncxx::v1::document::value.
Provides bsoncxx::v1::document::view.
Provides mongocxx::v1::gridfs::bucket.
Declares mongocxx::v1::pipeline.
Declares mongocxx::v1::read_concern.
Declares mongocxx::v1::read_preference.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Provides mongocxx::v1::write_concern.