So I have an application that allow users to create events with their friends, they can specify the time and duration of the event. What I want to do is that I want to delete the firestore document related to that event as soon as the event is finished (eventTime + eventDuration). I figured I would use cloud functions to achieve that by listening to onWrite event on all event documents, and then schedule deletion using setTimeout.
The thing is that if an event is edited, and the event time or duration is changed, I need to clear the first timeout and create a new one. To do so, I thought I would have to store the timeout reference in firestore, but I can't because the datatype is not supported.
I searched for a solution for this task but couldn't find anything useful for my application. Can anyone help ?
Thank you.