Добавлены описания

This commit is contained in:
Alexander Zhirov 2025-09-13 02:50:01 +03:00
parent 8716a90463
commit 8639c36f46
Signed by: alexander
GPG key ID: C8D8BE544A27C511
8 changed files with 388 additions and 34 deletions

View file

@ -369,10 +369,24 @@ public:
long deleteSnapshot(long id) {
auto queryResult = sql("DELETE FROM snapshots WHERE id = ? RETURNING id", id);
if (queryResult.empty()) {
throw new Exception("Ошибка при удалении снимка из базы данных");
if (!queryResult.empty()) {
return queryResult.front()["id"].to!long;
}
return 0;
}
long deleteSnapshot(string label) {
auto queryResult = sql(
q{
DELETE FROM snapshots
WHERE label = ?
RETURNING 1;
}, label);
if (!queryResult.empty()) {
return queryResult.length.to!long;
}
return queryResult.front()["id"].to!long;
return 0;
}
}

View file

@ -137,6 +137,23 @@ public:
return snapshot;
}
// Удаляет снимок по метке, возвращает количество удаленных снимков
long removeSnapshots(string label) {
return _db.deleteSnapshot(label);
}
bool removeSnapshots(Snapshot snapshot) {
return removeSnapshots(snapshot.id);
}
bool removeSnapshots(long idSnapshot) {
return _db.deleteSnapshot(idSnapshot) == idSnapshot;
}
Snapshot getSnapshot(long idSnapshot) {
return new Snapshot(_db, idSnapshot);
}
Snapshot[] getSnapshots(string label = string.init) {
Snapshot[] snapshots;

View file

@ -1,3 +1,3 @@
module cdcdb.version_;
enum cdcdbVersion = "0.0.1";
enum cdcdbVersion = "0.1.0";