16 std::vector<uint8_t> out(
sizeof(
MyStruct));
17 std::memcpy(out.data(),
this,
sizeof(
MyStruct));
24 std::memcpy(&out, data,
sizeof(
MyStruct));
36 auto txn = conn->transaction();
41# if __cplusplus >= 201703L
42 auto result = table.find(1, txn);
43 std::cout <<
"Key 1: " << result.value_or(
"not found") << std::endl;
47 std::cout <<
"Key 1: " << result.second << std::endl;
49 std::cout <<
"Key 1: not found" << std::endl;
Declaration of the KeyValueTable class for managing key-value pairs in an MDBX database.
Parameters used by Connection to create the MDBX environment.
std::string pathname
Path to the database file or directory containing the database.
static std::shared_ptr< Connection > create(const Config &config)
Creates and connects a new shared Connection instance.
Template class for managing key-value pairs in an MDBX database.
void insert_or_assign(const KeyT &key, const ValueT &value, MDBX_txn *txn=nullptr)
Inserts or replaces key-value pair.
std::pair< bool, ValueT > find_compat(const KeyT &key, MDBX_txn *txn=nullptr) const
Finds value by key.
void clear(MDBX_txn *txn=nullptr)
Clears all key-value pairs from the database.
Shows scoped transaction usage.
static MyStruct from_bytes(const void *data, size_t size)
std::vector< uint8_t > to_bytes() const