Loading...
Searching...
No Matches
database.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/v1/database-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/document/value-fwd.hpp>
#include <mongocxx/v1/client_session-fwd.hpp>
#include <mongocxx/v1/collection-fwd.hpp>
#include <mongocxx/v1/cursor-fwd.hpp>
#include <mongocxx/v1/pipeline-fwd.hpp>
#include <mongocxx/v1/read_concern-fwd.hpp>
#include <mongocxx/v1/read_preference-fwd.hpp>
#include <bsoncxx/v1/document/view.hpp>
#include <bsoncxx/v1/stdx/optional.hpp>
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <mongocxx/v1/aggregate_options.hpp>
#include <mongocxx/v1/change_stream.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <mongocxx/v1/gridfs/bucket.hpp>
#include <mongocxx/v1/write_concern.hpp>
#include <cstdint>
#include <string>
#include <vector>
namespace mongocxx {
namespace v1 {
class database {
private:
class impl;
void* _impl;
public:
MONGOCXX_ABI_EXPORT_CDECL() ~database();
MONGOCXX_ABI_EXPORT_CDECL() database(database&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(database&) operator=(database&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() database(database const& other);
MONGOCXX_ABI_EXPORT_CDECL(database&) operator=(database const& other);
MONGOCXX_ABI_EXPORT_CDECL() database();
explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) aggregate(
v1::pipeline const& pipeline,
v1::aggregate_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor)
aggregate(v1::client_session const& session, v1::pipeline const& pipeline, v1::aggregate_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::value) run_command(bsoncxx::v1::document::view command);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::value) run_command(
v1::client_session const& session,
bsoncxx::v1::document::view command);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::value) run_command(
bsoncxx::v1::document::view command,
std::uint32_t server_id);
MONGOCXX_ABI_EXPORT_CDECL(v1::collection) create_collection(
bsoncxx::v1::stdx::string_view name,
bsoncxx::v1::document::view opts = {},
bsoncxx::v1::stdx::optional<v1::write_concern> const& wc = {});
MONGOCXX_ABI_EXPORT_CDECL(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 = {});
MONGOCXX_ABI_EXPORT_CDECL(void) drop(bsoncxx::v1::stdx::optional<v1::write_concern> const& wc = {});
MONGOCXX_ABI_EXPORT_CDECL(void) drop(
v1::client_session const& session,
bsoncxx::v1::stdx::optional<v1::write_concern> const& wc = {});
MONGOCXX_ABI_EXPORT_CDECL(bool) has_collection(bsoncxx::v1::stdx::string_view name);
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) list_collections(bsoncxx::v1::document::view filter = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) list_collections(
v1::client_session const& session,
bsoncxx::v1::document::view filter = {});
MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_collection_names(bsoncxx::v1::document::view filter = {});
MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_collection_names(
v1::client_session const& session,
bsoncxx::v1::document::view filter = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::string_view) name() const;
MONGOCXX_ABI_EXPORT_CDECL(void) read_concern(v1::read_concern const& rc);
MONGOCXX_ABI_EXPORT_CDECL(v1::read_concern) read_concern() const;
MONGOCXX_ABI_EXPORT_CDECL(void) read_preference(v1::read_preference const& rp);
MONGOCXX_ABI_EXPORT_CDECL(v1::read_preference) read_preference() const;
MONGOCXX_ABI_EXPORT_CDECL(void) write_concern(v1::write_concern const& wc);
MONGOCXX_ABI_EXPORT_CDECL(v1::write_concern) write_concern() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::collection) collection(bsoncxx::v1::stdx::string_view name) const;
MONGOCXX_ABI_EXPORT_CDECL(v1::collection) operator[](bsoncxx::v1::stdx::string_view name) const;
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::bucket) gridfs_bucket(v1::gridfs::bucket::options const& opts = {}) const;
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(v1::change_stream::options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(
v1::client_session const& session,
v1::change_stream::options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(
v1::pipeline const& pipeline,
v1::change_stream::options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream)
watch(v1::client_session const& session, v1::pipeline const& pipeline, v1::change_stream::options const& opts = {});
class internal;
private:
/* explicit(false) */ database(void* impl);
};
} // namespace v1
} // namespace mongocxx
#include <mongocxx/v1/detail/postlude.hpp>
aggregate_options.hpp
Provides mongocxx::v1::aggregate_options.
bsoncxx::v1::document::value
A BSON document.
Definition value.hpp:44
bsoncxx::v1::document::view
A non-owning, read-only BSON document.
Definition view.hpp:52
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
mongocxx::v1::aggregate_options
Options for an "aggregate" command.
Definition aggregate_options.hpp:62
mongocxx::v1::change_stream::options
Options for mongocxx::v1::change_stream.
Definition change_stream.hpp:170
mongocxx::v1::change_stream
A MongoDB change stream.
Definition change_stream.hpp:48
mongocxx::v1::client_session
A MongoDB client session.
Definition client_session.hpp:46
mongocxx::v1::collection
A MongoDB collection.
Definition collection.hpp:81
mongocxx::v1::cursor
A MongoDB cursor.
Definition cursor.hpp:39
mongocxx::v1::database::~database
~database()
Destroy this object.
mongocxx::v1::database::create_collection
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.
mongocxx::v1::database::collection
v1::collection collection(bsoncxx::v1::stdx::string_view name) const
Access the collection with the given name.
mongocxx::v1::database::watch
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.
mongocxx::v1::database::watch
v1::change_stream watch(v1::client_session const &session, v1::change_stream::options const &opts={})
Return a change stream subscribed to this database.
mongocxx::v1::database::watch
v1::change_stream watch(v1::change_stream::options const &opts={})
Return a change stream subscribed to this database.
mongocxx::v1::database::list_collection_names
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.
mongocxx::v1::database::write_concern
v1::write_concern write_concern() const
Return the current default "writeConcern" to use for operations on this database.
mongocxx::v1::database::list_collections
v1::cursor list_collections(bsoncxx::v1::document::view filter={})
Return an unsorted list of all collections and views in this database.
mongocxx::v1::database::run_command
bsoncxx::v1::document::value run_command(v1::client_session const &session, bsoncxx::v1::document::view command)
Run an arbitrary database command.
mongocxx::v1::database::read_concern
v1::read_concern read_concern() const
Return the current default "readConcern" to use for operations on this database.
mongocxx::v1::database::run_command
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.
mongocxx::v1::database::database
database()
Default initialization.
mongocxx::v1::database::name
bsoncxx::v1::stdx::string_view name() const
Return the name of this database.
mongocxx::v1::database::aggregate
v1::cursor aggregate(v1::pipeline const &pipeline, v1::aggregate_options const &opts={})
Run an aggregation framework pipeline.
mongocxx::v1::database::write_concern
void write_concern(v1::write_concern const &wc)
Set the default "writeConcern" to use for operations on this database.
mongocxx::v1::database::read_preference
void read_preference(v1::read_preference const &rp)
Set the default "readPreference" to use for operations on this database.
mongocxx::v1::database::run_command
bsoncxx::v1::document::value run_command(bsoncxx::v1::document::view command)
Run an arbitrary database command.
mongocxx::v1::database::gridfs_bucket
v1::gridfs::bucket gridfs_bucket(v1::gridfs::bucket::options const &opts={}) const
Return a GridFS bucket for this database.
mongocxx::v1::database::read_concern
void read_concern(v1::read_concern const &rc)
Set the default "readConcern" to use for operations on this database.
mongocxx::v1::database::drop
void drop(v1::client_session const &session, bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={})
Drop this database and all associated data files.
mongocxx::v1::database::list_collection_names
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.
mongocxx::v1::database::database
database(database &&other) noexcept
Move constructor.
mongocxx::v1::database::list_collections
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.
mongocxx::v1::database::has_collection
bool has_collection(bsoncxx::v1::stdx::string_view name)
Return true when this database contains a collection with the given name.
mongocxx::v1::database::read_preference
v1::read_preference read_preference() const
Return the current default "readPreference" to use for operations on this database.
mongocxx::v1::database::create_collection
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.
mongocxx::v1::database::drop
void drop(bsoncxx::v1::stdx::optional< v1::write_concern > const &wc={})
Drop this database and all associated data files.
mongocxx::v1::database::operator[]
v1::collection operator[](bsoncxx::v1::stdx::string_view name) const
Equivalent to this->collection(name).
mongocxx::v1::gridfs::bucket::options
Options for mongocxx::v1::gridfs::bucket.
Definition bucket.hpp:335
mongocxx::v1::gridfs::bucket
A GridFS bucket.
Definition bucket.hpp:60
mongocxx::v1::pipeline
A MongoDB aggregation pipeline.
Definition pipeline.hpp:41
mongocxx::v1::read_concern
Options related to a MongoDB Read Concern.
Definition read_concern.hpp:42
mongocxx::v1::read_preference
Options related to a MongoDB Read Preference.
Definition read_preference.hpp:47
mongocxx::v1::write_concern
Options related to a MongoDB Write Concern.
Definition write_concern.hpp:47
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
mongocxx::options
Declares entities representing options to use with various commands.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
change_stream.hpp
Provides mongocxx::v1::change_stream.
client_session-fwd.hpp
Declares mongocxx::v1::client_session.
collection-fwd.hpp
Declares mongocxx::v1::collection.
cursor-fwd.hpp
Declares mongocxx::v1::cursor.
database-fwd.hpp
Declares mongocxx::v1::database.
value-fwd.hpp
Declares bsoncxx::v1::document::value.
view.hpp
Provides bsoncxx::v1::document::view.
bucket.hpp
Provides mongocxx::v1::gridfs::bucket.
pipeline-fwd.hpp
Declares mongocxx::v1::pipeline.
read_concern-fwd.hpp
Declares mongocxx::v1::read_concern.
read_preference-fwd.hpp
Declares mongocxx::v1::read_preference.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
write_concern.hpp
Provides mongocxx::v1::write_concern.