My app allows users to post and sign up for different events that occur in the future. I'm stuck on finding a way to delete a certain event once it has completed. For example, a user creates an event that starts on October 8th and ends on October 10th. Once October 10th passes, I want the database to move or delete the event. I have no idea whether this is done with server-side code or with code within the app.
Asked
Active
Viewed 201 times
3 Answers
1
There is currently no way to trigger some action based on the passage of a point in time. Your best option is to create a cron-like job that invokes a Cloud Function that periodically searches for and cleans up expired data.
Read this blog for more info, and see this sample code.

Doug Stevenson
- 297,357
- 32
- 422
- 441
0
On method is a scheduled job that essentially does:
delete from t
where date 'now' > end_date;
I would vote for actually setting a flag on the event or moving it to another table -- deleting history always seems dangerous to me.

Gordon Linoff
- 1,242,037
- 58
- 646
- 786
0
I have done something similar but in another way. U can try this. Actually, it is not an automated process. someone have to call or data when data arrived i checked the time and did this
//Moving to new url
FirebaseDatabase.getInstance().getReference().child("newUrl")
.setValue(DATA);
//Deleting from current url
FirebaseDatabase.getInstance().getReference().child("oldUrl")
.child("keyOfYourData")
.removeValue();
did this before populating the data. hope in this way your job will be done.

Shahadat Hossain Shaki
- 796
- 7
- 15