Skip to content

Commit

Permalink
Add document reading to minimal example
Browse files Browse the repository at this point in the history
  • Loading branch information
avsej committed Jun 26, 2024
1 parent f336705 commit 5356624
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions examples/minimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,31 @@ main()
.collection(config.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.message() << ", ";
{
const tao::json::value basic_doc{
{ "a", 1.0 },
{ "b", 2.0 },
};

auto [err, resp] = collection.upsert(document_id, basic_doc, {}).get();
std::cout << "Upsert id: " << document_id;
if (err.ec()) {
std::cout << ", Error: " << err.message() << "\n";
} else {
std::cout << ", CAS: " << resp.cas().value() << "\n";
}
}
{
auto [err, resp] = collection.get(document_id, {}).get();
std::cout << "Get id: " << document_id;
if (err.ec()) {
std::cout << ", Error: " << err.message() << "\n";
} else {
std::cout << ", CAS: " << resp.cas().value() << "\n";
std::cout << tao::json::to_string(resp.content_as<tao::json::value>()) << "\n";
}
}
std::cout << "id: " << document_id << ", CAS: " << resp.cas().value() << "\n";
}

cluster.close().get();
Expand Down

0 comments on commit 5356624

Please sign in to comment.