aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPitu <[email protected]>2020-05-10 21:22:25 +0900
committerPitu <[email protected]>2020-05-10 21:22:25 +0900
commitb27b4c47f79071d3aa336b8f9a6578103df56fe9 (patch)
tree245731fa39fa60aa6be213cea670fa5a7993afc3 /src
parentSmall fix for migration script, dont import deleted albums (diff)
downloadhost.fuwn.me-b27b4c47f79071d3aa336b8f9a6578103df56fe9.tar.xz
host.fuwn.me-b27b4c47f79071d3aa336b8f9a6578103df56fe9.zip
feat: Proper deleting of albums
Diffstat (limited to 'src')
-rw-r--r--src/api/routes/albums/albumDELETE.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/api/routes/albums/albumDELETE.js b/src/api/routes/albums/albumDELETE.js
index 96698b4..4e6640e 100644
--- a/src/api/routes/albums/albumDELETE.js
+++ b/src/api/routes/albums/albumDELETE.js
@@ -17,10 +17,18 @@ class albumDELETE extends Route {
if (!album) return res.status(400).json({ message: 'The album doesn\'t exist or doesn\'t belong to the user' });
try {
- /*
- Delete the album
- */
+ // Delete the album
await db.table('albums').where({ id }).delete();
+
+ // Delete the relation of any files attached to this album
+ await db.table('albumsFiles').where({ albumId: id }).delete();
+
+ // Delete the relation of any links attached to this album
+ await db.table('albumsLinks').where({ albumId: id }).delete();
+
+ // Delete any album links created for this album
+ await db.table('links').where({ albumId: id }).delete();
+
return res.json({ message: 'The album was deleted successfully' });
} catch (error) {
return super.error(res, error);