This commit is contained in:
Your Name
2025-05-03 09:36:54 +12:00
parent ceb31057a9
commit 66cfde013c
14 changed files with 92 additions and 40 deletions

34
src/database.hpp Normal file
View File

@@ -0,0 +1,34 @@
#ifndef DATABASE_HPP
#define DATABASE_HPP
#include <filesystem>
#include <string>
#include <sqlite3.h>
#include <json.hpp>
namespace simple_object_storage {
class dbEntry {
public:
std::string label_tag; // unique identifier for the object
std::string hash; // hash of the object - not unique
nlohmann::json metadata;
};
class Database {
public:
Database(const std::filesystem::path& path);
~Database();
bool insert(const dbEntry& entry);
bool remove(const std::string& label_tag);
bool get(const std::string& label_tag, dbEntry& entry);
bool update(const std::string& label_tag, const dbEntry& entry);
bool list(std::vector<dbEntry>& entries);
private:
std::filesystem::path path_;
sqlite3* db_;
};
} // namespace simple_object_storage
#endif // DATABASE_HPP