0

I am trying to implement a method where a post(s) will be deleted after a given time frame. In my case 10 weeks.

How would I go about implementing a feature? I've read that Firebase does not support server-sided scripting. So how could I go about it? When users uploads a post, I do have a timestamp node attached. Is it a case of comparing the post's timestamp to a timestamp of 10 weeks? And then removing the post? Or is there another, more efficient way to achieve such a thing?

If I was to implement the aforementioned method, this would mean I'd require an observer/method to first analyse ALL posts, then do the comparison and then execute the second phase, depending on the timestamp - removeValue or simply return. And I wouldn't I need to use NotificatonCenter so I can call this code throughout my whole app?

Any input/advice would be appreciated.

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
iSwift
  • 15
  • 6
  • Firebase **does** nowadays have a way to run server-side code, in the form of Cloud Functions. See my answer here for how to delete obsolete data with that: https://stackoverflow.com/questions/32004582/delete-firebase-data-older-than-2-hours, which also made it into the [functions-samples repo](https://github.com/firebase/functions-samples/tree/master/delete-old-child-nodes) – Frank van Puffelen Dec 22 '17 at 23:38
  • @FrankvanPuffelen Thanks for your reply. What language is used to perform Cloud Functions? – iSwift Dec 22 '17 at 23:42
  • Cloud Functions can currently only be written in JavaScript. – Frank van Puffelen Dec 23 '17 at 02:31

0 Answers0