This commit is contained in:
Your Name
2025-05-03 15:08:25 +12:00
parent 7df5c75539
commit c456fb4225
6 changed files with 237 additions and 25 deletions

View File

@@ -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;