Working
This commit is contained in:
@@ -166,6 +166,20 @@ bool Database::remove(const std::string& label_tag) {
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Database::remove_by_hash(const std::string& hash) {
|
||||
std::string sql = "DELETE FROM objects WHERE hash = ?;";
|
||||
sqlite3_stmt* stmt;
|
||||
|
||||
if (sqlite3_prepare_v2(db_, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sqlite3_bind_text(stmt, 1, hash.c_str(), -1, SQLITE_STATIC);
|
||||
bool success = sqlite3_step(stmt) == SQLITE_DONE;
|
||||
sqlite3_finalize(stmt);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Database::get(const std::string& label_tag, dbEntry& entry) {
|
||||
std::string sql = "SELECT hash, metadata FROM objects WHERE label_tag = ?;";
|
||||
sqlite3_stmt* stmt;
|
||||
|
Reference in New Issue
Block a user