MongoDB C++ Driver 4.4.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
55class database {
56 private:
57 class impl;
58 void* _impl;
59
60 public:
67
75
82 MONGOCXX_ABI_EXPORT_CDECL(database&) operator=(database&& other) noexcept;
83
88
92 MONGOCXX_ABI_EXPORT_CDECL(database&) operator=(database const& other);
93
101
105 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
106
115 v1::pipeline const& pipeline,
116 v1::aggregate_options const& opts = {});
117
119 aggregate(v1::client_session const& session, v1::pipeline const& pipeline, v1::aggregate_options const& opts = {});
122
136
138 v1::client_session const& session,
142
156 std::uint32_t server_id);
157
172
174 v1::client_session const& session,
180
192
194 v1::client_session const& session,
198
206
218
220 v1::client_session const& session,
221 bsoncxx::v1::document::view filter = {});
224
236
238 v1::client_session const& session,
239 bsoncxx::v1::document::view filter = {});
242
247
257
262
272
277
287
292
297
302
313
322
324 v1::client_session const& session,
325 v1::change_stream::options const& opts = {});
328
337 v1::pipeline const& pipeline,
338 v1::change_stream::options const& opts = {});
339
341 watch(v1::client_session const& session, v1::pipeline const& pipeline, v1::change_stream::options const& opts = {});
344
345 class internal;
346
347 private:
348 /* explicit(false) */ database(void* impl);
349};
350
351} // namespace v1
352} // namespace mongocxx
353
355
Provides mongocxx::v1::aggregate_options.
A BSON document.
Definition value.hpp:44
A non-owning, read-only BSON document.
Definition view.hpp:52
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:62
Options for mongocxx::v1::change_stream.
Definition change_stream.hpp:170
A MongoDB change stream.
Definition change_stream.hpp:48
A MongoDB client session.
Definition client_session.hpp:46
A MongoDB collection.
Definition collection.hpp:81
A MongoDB cursor.
Definition cursor.hpp:39
~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:335
A GridFS bucket.
Definition bucket.hpp:60
A MongoDB aggregation pipeline.
Definition pipeline.hpp:41
Options related to a MongoDB Read Concern.
Definition read_concern.hpp:42
Options related to a MongoDB Read Preference.
Definition read_preference.hpp:47
Options related to a MongoDB Write Concern.
Definition write_concern.hpp:47
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.