Willing To Pay $... Need help on API WF deleting multiple "Things" and files

Hello, thank you for looking!
I have been trying to solve this problem by myself for too long now and I feel like I will be better off paying someone for a solution compared to me wasting more time. I will gladly paypal you dinner/beer money if you can help me.

PROBLEM:
In my app a user makes a LISTING (datatype) and each LISTING has 3 other datatypes hooked to it. I want the listing to self delete after 30 days along with all other datatypes and files affiliated with it.
I have only been able to figure out how to delete the LISTING datatype and not the other datatypes and files affiliated with it.
Deleting the files affiliated with it is huge due to these are pictures files that are stored on Bubble/AWS and I do not want these to take up space when not in use.
I have read somewhere that the files and related datatypes need to be deleted prior the the Parent datatype due to there will no connection on what datatypes belong to what. Is this true?

I have attached a diagram of my database. If you choose to help me, please explain it like Im in 6th grade. Thank you very much in advance!

You’re right about needing to delete the related datatypes and files first before you delete the parent LISTING datatype. If you delete the LISTING first, there’s no way to trace back to the other datatypes and files related to it.

Now, here’s a simple step-by-step process to get this done. Note that this is a generalized example, and you might need to tweak it a bit based on your specific app structure.

  1. First, you’ll need to set up an API workflow on the LISTING datatype. To do this, go to the Backend workflows in your Bubble dashboard and create a new API endpoint. Let’s name this endpoint “Delete_Listing_and_Related_Items”. This endpoint will be responsible for deleting all the data.

  2. Within this new workflow, you will need to create actions to delete each of the related datatypes and files.

  3. You’ll then create another action that deletes the LISTING datatype itself.

Here’s how to do that in more detail:

A. Deleting related datatypes:

  • Create an action with the type “Data (Things) > Delete a list of things”.
  • For the type, select the related datatype you want to delete.
  • For the list to delete, use the expression This Listing's [related datatype], replacing [related datatype] with the actual name of the related datatype.

Repeat this step for each of the related datatypes.

B. Deleting files:

  • Create another action of the same type (“Data (Things) > Delete a list of things”).
  • For the type, select “File”.
  • For the list to delete, use the expression This Listing's [related files field], replacing [related files field] with the name of the field where you’re storing the files in the LISTING datatype.

C. Deleting the LISTING:

  • Finally, create one more action with the type “Data (Things) > Delete a thing”.
  • For the thing to delete, simply use This Listing.
  1. Now you need to schedule this workflow to run 30 days after a LISTING is created. You can do this by going to the workflow that creates a LISTING and adding an action at the end:
  • Add an action of the type “Scheduling > Schedule an API Workflow on a date”.
  • For the API workflow to schedule, select “Delete_Listing_and_Related_Items”.
  • For the date, use the expression This Listing's Creation Date + (30days). This will add 30 days to the creation date.
  • For the thing to delete, use This Listing.

That should take care of it!

Dang! @Benjamin_Rodgers what a great explanation!! I am going to give it a go right now. Thank you so much. Give me a few minutes (hopefully) to know this out and I will get right back with you.
Thank you once again, that was a great explanation.

@Benjamin_Rodgers … I must be doing something wrong due to it still just erases the LISTING and nothing else. I have a headache and Im going to step away for a bit and try again after lunch. Thank you again for your help.