0

I am trying to make auto/self delete or mark data with deleted of 1 minute old data. But I failing to make it in firebase realtime database.

Can anyone help me to make it in firebase nodejs app.

I am trying to create nodejs function as Time-To-Live(TTL) functionality.

Appreciate your help.

  • This topic has been covered quite regularly before like in https://stackoverflow.com/q/32004582, which even led to a Cloud Functions example here: https://github.com/firebase/functions-samples/tree/master/delete-old-child-nodes. I'd recommend reading some of those approaches and trying this yourself. If you get stuck along the way, post back with what you tried and we can probably help better. – Frank van Puffelen Jun 04 '20 at 15:49

1 Answers1

0

Realtime Database doesn't have a TTL feature. You will have to build this yourself. One approach is to use Cloud Functions in tandem with Cloud Tasks to schedule a task to run 1 minute after you write a child in the database, which would invoke the function to delete it.

I have a more complete and detailed explanation of how that works with Firestore, but you will have to substitute Realtime Database for Firestore.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441