When item is older than 30 days then delete from database

Hello Bubblers!

I would like to automatically delete items from my database after 30 days after it has been listed, how do I do this?

for example: A person uploads an item on Jan 1st and then it will automatically get deleted on Feb 1st

When you create the thing, just schedule a backend workflow for 30 days time that deletes the thing.

2 Likes

Thanks Adam!

1 Like

Don’t forget to Delete the uploaded file as well, not only the database record. These are two seperate actions

1 Like

Thanks for the extra Tip!

1 Like

I wouldn’t advise proceeding in that manner, as it would result in an accumulation of Scheduled Workflows for each individual item created. A more efficient approach could be to establish a workflow that scans your database for entries older than 30 days and deletes them. This workflow could then be executed on a monthly basis.

1 Like

That will lead to items up to 61 days old in the database…

The OP was asking how to delete something 30 days after it’s created - the ONLY way to accurately do that is to schedule a workflow to delete it 30 days after it’s created.

If that kind of accuracy isn’t required then you can periodically check the database (as you’ve suggested) - which may or may not be more efficient (it depends entirely on the specific number of things involved and how often you check them) but much less accurate.

The more accuracy you need, the more often you need to check the database (i.e. every day, every hour, every 15 minutes etc.).

Checking the database every month will lead to wild inaccuracies here (up to 31 days, as I already pointed out) but will be very efficient.

Checking the database every day will be much more accurate (but can still be up to 24 hours out), and if there are things being deleted every day, probably more efficient (whereas if things are only being deleted every few days, then this method will be less efficient).

Checking every hour, will be even more accurate, and still more efficient if there are multiple things being deleted every hour - but if many hours nothing gets deleted, it will be less efficient.

So, it’s certainly not as simple as saying one thing is more efficient than another - there are many factors involved, and in this case you trade accuracy for efficiency.

If efficiency is what you need (and accuracy is not important) then check the database less often. (i.e. once a month)

If accuracy is what you need, either check it more often, or (if you need 100% accuracy) schedule the deletion for a precise time.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.