Hello fellow bubblers
i am trying to learn a backend workflow …i saw a database trigger event in backend.
i have two table one named car and other is company.
when i am deleting a company all cars belongs to that company from car table also be removed.
i used things now in a condition but it is not removing all the rows from car belongs to that particular company.
can any of you guide me how to use that functionality in bubble?
Hello,
I wasn’t able to fully understand what you’re trying to do. Could you please elaborate?
Not sure if you’re trying to use database trigger in a wrong way but to simplify what a database trigger does is that it watches things in your database and lets you decide an action if there are changes.
You could use database triggers when:
- A thing is created
- A thing is deleted
- A thing is changed
If I understand it correctly, are you aiming to delete all cars when you delete a company?
Hi ntabs
thank you for taking time and making effort, appreciate that
yes thats exactly what i meant…
here i have two tables Car and A comapany
in car table i have company reference.
all i want is when i delete a company all cars should be deleted belongs to that company.
i am trying to do this on deleting a thing.
tried everything a thing before change is not empty a thing now is empty but it is not doing anything i dont know where i am making mistake so thought this would be a platform to get help from experienced fellows like you guys
Once you delete a company, it’s gone… so no cars will be associated with that company (as it no longer exists)…
So if you’re trying to delete a list of cars associated with that company (which no longer exists), that list will contain zero cars, so nothing will be deleted…
If you want to delete the cars associated with the company, you’ll need to delete them first, before the company is deleted.
Yes, you would need to delete the cars first like what Adam said.
Thanks for helping out @adamhholmes
Yes thats exactly i did had to trigger a workflow where i delete a car where the comapany is list of companies first item which was a reference to car table.
thank you for a suggestion.
appreciate adam and ntabs for sparing a time
Happy to hear that you were able to do what you wanted.
However, I think you were able to do what you wanted because your current workflow
where you delete a car that has company = list of companies: first item was able to reference to the company that you were aiming for because you only have 1 company in your database at the moment.
However, as you add more cars and companies, this workflow won’t work.
To be precise, you would need to delete a car only if car’s company is the exact company that car is related to.
There could be a lot of ways to reference to that company but to name a few that could be:
company = parent group’s company
or
company = current page’s company
Hope this helps