diff options
| -rw-r--r-- | src/api/routes/albums/albumDELETE.js | 14 |
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); |