#include <iostream>
#include <system_error>
static constexpr auto connection_string{ "couchbase://127.0.0.1" };
static constexpr auto username{ "Administrator" };
static constexpr auto password{ "password" };
static constexpr auto bucket_name{ "default" };
int
main()
{
options.apply_profile("wan_development");
if (connect_err) {
std::cout << "Unable to connect to the cluster. ec: " << fmt::format("{}", connect_err) << "\n";
} else {
auto collection = cluster.bucket(bucket_name).scope(scope_name).collection(collection_name);
const std::string document_id{ "minimal_example" };
const tao::json::value basic_doc{
{ "a", 1.0 },
{ "b", 2.0 },
};
auto [err, resp] = collection.upsert(document_id, basic_doc, {}).get();
if (err.ec()) {
std::cout << "ec: " << err.ec().message() << ", ";
}
std::cout << "id: " << document_id << ", CAS: " << resp.cas().value() << "\n";
}
cluster.close().get();
return 0;
}
Definition cluster_options.hxx:44
static void connect(const std::string &connection_string, const cluster_options &options, cluster_connect_handler &&handler)
Connect to a Couchbase cluster.
static constexpr auto default_name
Constant for the name of the default collection in the bucket.
Definition collection.hxx:78
static constexpr auto default_name
Constant for the name of the default scope in the bucket.
Definition scope.hxx:55
void initialize_console_logger()
void set_level(log_level level)