aboutsummaryrefslogtreecommitdiff
path: root/src/example/db.cpp
diff options
context:
space:
mode:
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..c046421
--- /dev/null
+++ b/src/example/db.cpp
@@ -0,0 +1,30 @@
+#include <crepe/facade/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 = Config::get_instance();
+ cfg.log.level = 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;
+}