21 table.insert_or_assign(10,
"ten");
22 table.insert_or_assign(20,
"twenty");
28 std::cout <<
"Key 20 (operator[]): " <<
static_cast<std::string
>(table[20]) << std::endl;
32 std::cout <<
"Key 30 (at): " << table.at(30) << std::endl;
33 }
catch (
const std::out_of_range&) {
34 std::cout <<
"Key 30 not found" << std::endl;
37# if __cplusplus >= 201703L
38 auto result = table.find(10);
39 std::cout <<
"Key 10 (find): " << result.value_or(
"not found") << std::endl;
41 auto result = table.find_compat(10);
43 std::cout <<
"Key 10 (find): " << result.second << std::endl;
45 std::cout <<
"Key 10 (find): 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.
int main()
Basic example using Config to initialize a table.
@ WRITABLE
Writable transaction (allows inserts, updates, deletes).