Bug fixing

This commit is contained in:
Your Name
2025-05-25 12:32:06 +12:00
parent 9308f4d719
commit 477d06d3bf
6 changed files with 261 additions and 207 deletions

View File

@@ -11,22 +11,21 @@ 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
std::string hash; // unique primary key
std::vector<std::string> labels; // multiple labels
std::vector<std::string> tags; // multiple tags
nlohmann::json metadata;
};
class Database {
public:
static const int CURRENT_VERSION = 1;
static const int CURRENT_VERSION = 2;
Database(const std::filesystem::path& path);
~Database();
bool insert(const dbEntry& entry);
bool remove(const std::string& label_tag);
bool remove(const std::string& hash);
bool remove_by_hash(const std::string& hash);
bool get(const std::string& label_tag, dbEntry& entry);
bool update(const std::string& label_tag, const dbEntry& entry);
bool get(const std::string& hash, dbEntry& entry);
bool list(std::vector<dbEntry>& entries);
bool update_or_insert(const dbEntry& entry);
private:
@@ -37,6 +36,7 @@ class Database {
bool getVersion(int& version);
bool setVersion(int version);
bool migrate(int from_version, int to_version);
bool createObjectsTable();
};
} // namespace simple_object_storage