Back

Does appwrite support TTL

  • 0
  • Web
Hexi
16 Nov, 2023, 12:04

Hi I wanted to create a appwrite document that expires after a hour. Would that be possible that it automatically deletes it self at Appwrite itself? Or do I have to manually code this feuture and for loop each time to check if there are not expirations. Maybe queries would work to check for a certain time stamp. But it would be nice if it would be possible to use TTL

TL;DR
Appwrite currently does not support TTL (Time-To-Live) for automatically deleting documents. However, you can create a function that runs every hour to check for expired documents and delete them. There is a pull request on GitHub to add this functionality to the function templates, but in the meantime, you can use the code provided in the pull request to create your own function.
Kenny
16 Nov, 2023, 14:54

I think, right now, the only way to achieve this is to create a function that runs every hour and checks for expired documents and deletes them.

There is a PR out to add that functionality to the function templates. But you should be fine to grap this code and make it your own function. https://github.com/appwrite/templates/pull/238/files

Kenny
16 Nov, 2023, 14:55

You may have to alter it slightly to support hours instead of just days.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more