add route to list backups by site

This commit is contained in:
Girish Ramakrishnan
2025-10-06 14:10:29 +02:00
parent 1b33b2c48c
commit 43962c4a5a
5 changed files with 48 additions and 0 deletions
+13
View File
@@ -9,6 +9,7 @@ exports = module.exports = {
update,
setState,
list,
listBySiteId,
del,
removePrivateFields,
@@ -195,6 +196,18 @@ async function list(page, perPage) {
return results;
}
async function listBySiteId(siteId, page, perPage) {
assert.strictEqual(typeof siteId, 'string');
assert(typeof page === 'number' && page > 0);
assert(typeof perPage === 'number' && perPage > 0);
const results = await database.query(`SELECT ${BACKUPS_FIELDS} FROM backups WHERE siteId=? ORDER BY creationTime DESC LIMIT ?,?`, [ siteId, (page-1)*perPage, perPage ]);
results.forEach(function (result) { postProcess(result); });
return results;
}
async function del(id) {
assert.strictEqual(typeof id, 'string');