Skip to content

C API Documentation

Jonas Schnelli edited this page Aug 20, 2016 · 3 revisions

Open / Flush and Close a Database

/* create a new database object */
logdb_log_db *db = logdb_new();
enum logdb_error error = 0;

/* create a database file (will overwrite existing) */
bool create = true;
logdb_load(db, "/tmp/test.logdb", create, &error);

/* append a record */
cstring *value = cstr_new("testkey");
cstring *key = cstr_new("somevalue");
/* second parameter NULL means we don't use a transaction */
logdb_append(db, NULL, key, value);

/* flush database (write its state to disk) */
logdb_flush(db);

/* cleanup */
logdb_free(db);
cstr_free(key);
cstr_free(value);
Clone this wiki locally