Back

how to delete document after certain time in a collection

  • 0
  • Self Hosted
  • Flutter
  • Databases
  • Functions
Ireneus
30 Jun, 2024, 17:09

how can i achieve this the best way are there any limitations?

TL;DR
Create a hidden collection "delete-this-docs" and store document paths there. Use Appwrite server SDK within Appwrite function to read this collection and delete the respective documents. Mark documents to delete, create a function to delete them in bulk, and schedule with cron. No major limitations for this setup.
kamal.panara
30 Jun, 2024, 17:17

You can mark the document that needs to be deleted and then create a function that can delete marked documents in bulk, and then schedule that function using cron: learn more about scheduling here: https://appwrite.io/docs/products/functions/execute#schedule

Ireneus
30 Jun, 2024, 17:26

how do i mark a document?

kamal.panara
30 Jun, 2024, 17:30

okay, so for example create new collection called "delete-this-docs" that no one can access, and create attribute to store the document path. now you can keep adding docs here that you want to delete and then you can read this collection from Appwrite server SDK inside appwrite function, and delete all those docs from path stored and also delete record of that docs from "delete-this-docs" collection.

Learn more about server SDK here: https://appwrite.io/docs/sdks#server Learn more about function here: https://appwrite.io/docs/products/functions/functions

Ireneus
30 Jun, 2024, 17:33

ill take a look at it thanks

kamal.panara
30 Jun, 2024, 17:33

edited

Ireneus
30 Jun, 2024, 17:33

ok

Ireneus
30 Jun, 2024, 17:33
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