Db
This commit is contained in:
34
src/database.hpp
Normal file
34
src/database.hpp
Normal 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
|
Reference in New Issue
Block a user