-
Notifications
You must be signed in to change notification settings - Fork 0
Journal Meta
FelixTheC edited this page Mar 4, 2023
·
1 revision
- Each result of a transaction will be an instance of the
Journalclass this class has two propertiesMetaandData. - We will now look at the
Metaproperty
#include "query.hpp"
annadb::AnnaDB con {"jondoe", "passwd1234", "localhost", 10001};
con.connect();
auto val_1 = tyson::TySonObject::Number(10);
auto val_2 = tyson::TySonObject::String("fizzbuzz");
auto val_3 = tyson::TySonObject::Bool(false);
// pass the TySON Objects to the insert statement
query.insert(val_1, val_2, val_3);
// create a transaction
std::optional<Journal> answer = con.send(query);
if (answer)
{
// extract the Meta information
Meta meta_information = answer.value().meta();
}
con.close();- the
MetaTypecan be any of theseMetaType::insert_metaMetaType::get_metaMetaType::find_metaMetaType::update_meta
- this can be used to validate that your transaction/query did what you expected
#include "query.hpp"
...
Meta meta_information = answer.value().meta();
if (meta_information.type() == MetaType::insert_meta)
{
...
}
...- you can either use the underlying TySON Map or directly the rows count
#include "query.hpp"
...
Meta meta_information = answer.value().meta();
// you can extract the rows count wall
// ewith an integral
short affected_rows = meta_information.rows<short>();
// or you can access the underlying TySON Map
tyson::TySonObject affected_rows = meta.data();
...