aboutsummaryrefslogtreecommitdiff
path: root/src/example/db.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-27 19:33:45 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-27 19:33:45 +0100
commitb2fc208fbdb55ecc3cba59e2dd51976ce829a4be (patch)
tree1a60e74b7533403831868b04943978987cec2c75 /src/example/db.cpp
parentecc5761fa78ccb57db958467c3fc999aceadd409 (diff)
WIP db facade
Diffstat (limited to 'src/example/db.cpp')
-rw-r--r--src/example/db.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/example/db.cpp b/src/example/db.cpp
new file mode 100644
index 0000000..b1ab196
--- /dev/null
+++ b/src/example/db.cpp
@@ -0,0 +1,30 @@
+#include <crepe/DB.h>
+#include <crepe/api/Config.h>
+#include <crepe/util/log.h>
+
+using namespace crepe;
+using namespace std;
+
+// run before main
+static auto _ = [] () {
+ auto & cfg = api::Config::get_instance();
+ cfg.log.level = util::LogLevel::TRACE;
+ return 0;
+}();
+
+int main() {
+ dbg_trace();
+
+ DB db("file.db");
+
+ const char * test_key = "test-key";
+ string test_data = "Hello world!";
+
+ dbg_logf("DB has key = %d", db.has(test_key));
+
+ db.set(test_key, test_data);
+
+ dbg_logf("key = \"%s\"", db.get(test_key).c_str());
+
+ return 0;
+}