MDBX Containers
Loading...
Searching...
No Matches
config_initialized_table.cpp
Go to the documentation of this file.
1
5
7#include <iostream>
8
9int main() {
10 mdbxc::Config config;
11 config.pathname = "one_table_db";
12 config.max_dbs = 1;
13
14 mdbxc::KeyValueTable<int, std::string> table(config, "single_table");
15 table.clear();
16 table.insert_or_assign(1, "example");
17# if __cplusplus >= 201703L
18 auto val = table.find(1);
19 std::cout << "Found: " << (val ? *val : "not found") << std::endl;
20# else
21 auto val = table.find_compat(1);
22 std::cout << "Found: " << (val.first ? val.second : "not found") << std::endl;
23# endif
24}
Declaration of the KeyValueTable class for managing key-value pairs in an MDBX database.
Parameters used by Connection to create the MDBX environment.
Definition Config.hpp:17
std::string pathname
Path to the database file or directory containing the database.
Definition Config.hpp:19
int64_t max_dbs
Maximum number of named databases (DBI) in the environment.
Definition Config.hpp:27
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.
int main()
Basic example using Config to initialize a table.