Skip to content

Update: Remove User's Artwork When Deleting User #51

@gent1999

Description

@gent1999

Description: Currently, when an admin deletes a user, only the user document is removed from the database. We need to implement a cascade delete so that all artwork associated with the deleted user (i.e., any images they uploaded) is also removed from the database and Cloudinary.

This ensures there’s no orphaned artwork left behind once a user is deleted.

Checklist:

  • Update the admin delete user endpoint to find and delete all images associated with the user.
  • Remove each image from both MongoDB and Cloudinary.
  • Use the user's _id to filter artwork in the ImageModel.
  • Extract and delete each image’s public_id from Cloudinary (artists folder if profile pic, or artwork folder if art).
  • Handle Cloudinary API errors gracefully (log, skip, and continue deleting others).
  • Test to confirm that:
  • User is deleted from the DB.
  • All of their artwork is removed from the DB.
  • All corresponding Cloudinary images are deleted.
  • Return a success response with a summary of deleted assets.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions