0

So, I'm creating an Android App to create and organize events for a school project.

I'm using Firebase and my Event skeleton looks like this

events

I want to delete events that have already happened, in this case, I would want the event above to be deleted at April 15th.

I know I can delete them on the app itself, or I can just filter them out so people don't see them when they run the app, but is there a way to do it on the firebase console?

Like, making a task that runs at 12 PM every day and checks for the system date, compares to the date of each event and deletes those which have already happened.

Thanks in advance.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Rui
  • 73
  • 2
  • 9
  • 1
    I think you are looking for [Firebase functions](https://firebase.google.com/docs/functions/) – André Kool Apr 09 '18 at 14:32
  • There is no built-in time-to-live in the Firebase Database. But as André says, you can easily build it yourself with Cloud Functions. For a simple example function, see [my answer here](https://stackoverflow.com/a/32012520/209103) or [this sample](https://github.com/firebase/functions-samples/tree/master/delete-old-child-nodes). – Frank van Puffelen Apr 09 '18 at 14:34
  • Note though that the format you store your data in is not ideal for selecting a date range. Since alphabetically `"April"` comes before `"March"`, a query from `"1 March"` to `"1 April"` will never match any nodes. It's best to store dates in a more suitable format, e.g. `"2018-03-01"` or as a timestamp. – Frank van Puffelen Apr 09 '18 at 14:36

0 Answers0