-
-
Notifications
You must be signed in to change notification settings - Fork 17
Labels
APIauthbackendduplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersjestonlydust-waveContribute to awesome OSS repos during OnlyDust's open source weekContribute to awesome OSS repos during OnlyDust's open source weektesting
Description
π Description
We need to update the album delete API endpoint so that when a user deletes an album:
- β The album gets deleted from the database
- β All images related to that album are also removed from the database
- β All images are also deleted from Cloudinary (where they are hosted)
π Current Problem
- When an album is deleted, the album gets removed.
- But the images related to that album may still stay in the database or remain in Cloudinary.
- This causes unnecessary storage use and data inconsistency.
β What Needs to Be Done
- Find all images related to the album in the database using the album ID or reference.
- Delete those images from Cloudinary using their public IDs.
- Delete those image documents from the database.
- Finally, delete the album from the database.
π§ Logic (Simple Steps):
// Example (pseudo-code)
const album = await Album.findById(albumId);
const images = await Image.find({ album: albumId });
// 1. Delete images from Cloudinary
for (let image of images) {
await cloudinary.uploader.destroy(image.public_id);
}
// 2. Delete image records from DB
await Image.deleteMany({ album: albumId });
// 3. Delete album from DB
await Album.findByIdAndDelete(albumId);π§ͺ How to Test
Create an album and upload multiple images to it.
-
Then call the delete album endpoint.
-
β Check if the album is removed from the DB.
-
β Check if related images are deleted from both the DB and Cloudinary.
π‘ Additional Suggestions
-
Add error handling for:
-
Cloudinary failures (e.g., retry or log)
-
Missing images or album
-
Optional: Add a confirmation step or warning before permanent deletion (for UI).
-
Optional: Add logging for deleted files (filename, public ID, etc.)
β° Priority: High
This is important to prevent junk data and unnecessary Cloudinary usage, which can increase storage cost.
#Β£ π Related Endpoints
DELETE /api/v1/admin/album/delete/AlbumId=
DELETE /api/images (or wherever images are stored)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
APIauthbackendduplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersjestonlydust-waveContribute to awesome OSS repos during OnlyDust's open source weekContribute to awesome OSS repos during OnlyDust's open source weektesting