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/database-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/database.hpp> // IWYU pragma: export
#include <cstdint>
#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
#include <string>
#include <utility>
#include <vector>
#include <mongocxx/client-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/client_encryption-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/collection-fwd.hpp>
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/document/view_or_value.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/stdx/string_view.hpp>
#include <bsoncxx/string/view_or_value.hpp>
#include <mongocxx/change_stream.hpp>
#include <mongocxx/client_session.hpp>
#include <mongocxx/collection.hpp>
#include <mongocxx/cursor.hpp>
#include <mongocxx/gridfs/bucket.hpp>
#include <mongocxx/options/aggregate.hpp>
#include <mongocxx/options/change_stream.hpp>
#include <mongocxx/options/gridfs/bucket.hpp>
#include <mongocxx/pipeline.hpp>
#include <mongocxx/read_concern.hpp>
#include <mongocxx/read_preference.hpp>
#include <mongocxx/write_concern.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
class database {
private:
v1::database _db;
public:
database() noexcept {}
database(database&& other) noexcept = default;
database& operator=(database&& other) noexcept = default;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() database(database const& other);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(database&) operator=(database const& other);
~database() = default;
/* explicit(false) */ database(v1::database database) : _db{std::move(database)} {}
explicit operator v1::database() && {
return std::move(_db);
}
explicit operator v1::database() const& {
return _db;
}
explicit operator bool() const noexcept {
return _db.operator bool();
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
aggregate(v_noabi::pipeline const& pipeline, v_noabi::options::aggregate const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
aggregate(
v_noabi::client_session const& session,
v_noabi::pipeline const& pipeline,
v_noabi::options::aggregate const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::document::value)
run_command(bsoncxx::v_noabi::document::view_or_value command);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::document::value)
run_command(v_noabi::client_session const& session, bsoncxx::v_noabi::document::view_or_value command);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::document::value)
run_command(bsoncxx::v_noabi::document::view_or_value command, std::uint32_t server_id);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::collection)
create_collection(
bsoncxx::v_noabi::stdx::string_view name,
bsoncxx::v_noabi::document::view_or_value collection_options = {},
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::collection)
create_collection(
v_noabi::client_session const& session,
bsoncxx::v_noabi::stdx::string_view name,
bsoncxx::v_noabi::document::view_or_value collection_options = {},
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop(bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
drop(
v_noabi::client_session const& session,
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bool)
has_collection(bsoncxx::v_noabi::string::view_or_value name) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
list_collections(bsoncxx::v_noabi::document::view_or_value filter = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
list_collections(v_noabi::client_session const& session, bsoncxx::v_noabi::document::view_or_value filter = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::vector<std::string>)
list_collection_names(bsoncxx::v_noabi::document::view_or_value filter = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::vector<std::string>)
list_collection_names(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::string_view) name() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) read_concern(v_noabi::read_concern rc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::read_concern) read_concern() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) read_preference(v_noabi::read_preference rp);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::read_preference) read_preference() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) write_concern(v_noabi::write_concern wc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::write_concern) write_concern() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::collection)
collection(bsoncxx::v_noabi::string::view_or_value name) const;
v_noabi::collection operator[](bsoncxx::v_noabi::string::view_or_value name) const {
return this->collection(name);
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::gridfs::bucket)
gridfs_bucket(v_noabi::options::gridfs::bucket const& options = {}) const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream) watch(
v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(v_noabi::client_session const& session, v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(v_noabi::pipeline const& pipe, v_noabi::options::change_stream const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::change_stream)
watch(
v_noabi::client_session const& session,
v_noabi::pipeline const& pipe,
v_noabi::options::change_stream const& options = {});
class internal;
};
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::database from_v1(v1::database v) {
return {std::move(v)};
}
inline v1::database to_v1(v_noabi::database v) {
return v1::database{std::move(v)};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
aggregate.hpp
Provides mongocxx::v_noabi::options::aggregate.
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
bsoncxx::v_noabi::document::value
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:48
mongocxx::database::database
database() noexcept
Default constructs a new database. The database is not valid for use and is equivalent to the state o...
Definition database.hpp:73
mongocxx::v1::database
A MongoDB database.
Definition database.hpp:55
mongocxx::v_noabi::change_stream
A MongoDB change stream.
Definition change_stream.hpp:44
mongocxx::v_noabi::client_session
Supports MongoDB client session operations.
Definition client_session.hpp:58
mongocxx::v_noabi::collection
A MongoDB collection.
Definition collection.hpp:98
mongocxx::v_noabi::cursor
A cursor over the documents returned by a query to a MongoDB server.
Definition cursor.hpp:50
mongocxx::v_noabi::database
A MongoDB database.
Definition database.hpp:63
mongocxx::v_noabi::database::aggregate
v_noabi::cursor aggregate(v_noabi::pipeline const &pipeline, v_noabi::options::aggregate const &options={})
Runs an aggregation framework pipeline against this database for pipeline stages that do not require ...
mongocxx::v_noabi::database::run_command
bsoncxx::v_noabi::document::value run_command(bsoncxx::v_noabi::document::view_or_value command)
Runs a command against this database.
mongocxx::v_noabi::database::create_collection
v_noabi::collection create_collection(bsoncxx::v_noabi::stdx::string_view name, bsoncxx::v_noabi::document::view_or_value collection_options={}, bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const &write_concern={})
Explicitly creates a collection in this database with the specified options.
mongocxx::v_noabi::database::read_preference
v_noabi::read_preference read_preference() const
The current read preference for this database.
mongocxx::v_noabi::database::name
bsoncxx::v_noabi::stdx::string_view name() const
Get the name of this database.
mongocxx::v_noabi::database::gridfs_bucket
v_noabi::gridfs::bucket gridfs_bucket(v_noabi::options::gridfs::bucket const &options={}) const
Access a GridFS bucket within this database.
mongocxx::v_noabi::database::operator=
database & operator=(database &&other) noexcept=default
Move assigns a database.
mongocxx::v_noabi::database::drop
void drop(bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const &write_concern={})
Drops the database and all its collections.
mongocxx::v_noabi::database::collection
v_noabi::collection collection(bsoncxx::v_noabi::string::view_or_value name) const
Access a collection (logical grouping of documents) within this database.
mongocxx::v_noabi::database::list_collection_names
std::vector< std::string > list_collection_names(bsoncxx::v_noabi::document::view_or_value filter={})
Enumerates the collection names in this database.
mongocxx::v_noabi::database::database
database(database &&other) noexcept=default
Move constructs a database.
mongocxx::v_noabi::database::database
database() noexcept
Default constructs a new database. The database is not valid for use and is equivalent to the state o...
Definition database.hpp:73
mongocxx::v_noabi::database::read_preference
void read_preference(v_noabi::read_preference rp)
Sets the read_preference for this database.
mongocxx::v_noabi::database::list_collections
v_noabi::cursor list_collections(bsoncxx::v_noabi::document::view_or_value filter={})
Enumerates the collections in this database.
mongocxx::v_noabi::database::read_concern
void read_concern(v_noabi::read_concern rc)
Sets the read_concern for this database.
mongocxx::v_noabi::database::write_concern
v_noabi::write_concern write_concern() const
The current write_concern for this database.
mongocxx::v_noabi::database::watch
v_noabi::change_stream watch(v_noabi::options::change_stream const &options={})
Gets a change stream on this database with an empty pipeline. Change streams are only supported with ...
mongocxx::v_noabi::database::read_concern
v_noabi::read_concern read_concern() const
The current read concern for this database.
mongocxx::v_noabi::database::write_concern
void write_concern(v_noabi::write_concern wc)
Sets the write_concern for this database.
mongocxx::v_noabi::database::has_collection
bool has_collection(bsoncxx::v_noabi::string::view_or_value name) const
Checks whether this database contains a collection having the given name.
mongocxx::v_noabi::gridfs::bucket
A GridFS bucket.
Definition bucket.hpp:74
mongocxx::v_noabi::options::change_stream
Used by change streams.
Definition change_stream.hpp:52
mongocxx::v_noabi::pipeline
A MongoDB aggregation pipeline.
Definition pipeline.hpp:45
mongocxx::v_noabi::read_concern
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
mongocxx::v_noabi::read_preference
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:59
mongocxx::v_noabi::write_concern
The level of acknowledgment requested for write operations to a MongoDB server.
Definition write_concern.hpp:54
view_or_value.hpp
Provides bsoncxx::v_noabi::document::view_or_value.
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::gridfs
Declares entities related to GridFS.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
view_or_value.hpp
Provides bsoncxx::v_noabi::string::view_or_value.
database.hpp
Provides mongocxx::v1::database.
value.hpp
Provides bsoncxx::v_noabi::document::value.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
change_stream.hpp
Provides mongocxx::v_noabi::change_stream.
client-fwd.hpp
Declares mongocxx::v_noabi::client.
client_encryption-fwd.hpp
Declares mongocxx::v_noabi::client_encryption.
client_session.hpp
Provides mongocxx::v_noabi::client_session.
collection-fwd.hpp
Declares mongocxx::v_noabi::collection.
collection.hpp
Provides mongocxx::v_noabi::collection.
cursor.hpp
Provides mongocxx::v_noabi::cursor.
database-fwd.hpp
Declares mongocxx::v_noabi::database.
bucket.hpp
Provides mongocxx::v_noabi::gridfs::bucket.
change_stream.hpp
Provides mongocxx::v_noabi::options::change_stream.
bucket.hpp
Provides mongocxx::v_noabi::options::gridfs::bucket.
pipeline.hpp
Provides mongocxx::v_noabi::pipeline.
read_concern.hpp
Provides mongocxx::v_noabi::read_concern.
read_preference.hpp
Provides mongocxx::v_noabi::read_preference.
write_concern.hpp
Provides mongocxx::v_noabi::write_concern.