2

I am coding an app using Swift and using Firebase to store data that users have inputted. I want that this data to reset daily, where the previous days data is cleared stored somewhere (maybe automatically downloads to an excel), and then fresh new data can be entered into Firebase. Is there a way to do this from Firebase? Or should my code perhaps do this from the Swift code itself?

Thanks!

  • There is nothing built into Firebase for that. But you can likely build it easily on top of Firebase, either in code, or by choosing a data model that matches. What database are you using? – Frank van Puffelen Jul 05 '18 at 13:10
  • Check this: https://github.com/firebase/functions-samples/tree/main/delete-old-child-nodes – Thiago Krempser Aug 25 '21 at 12:24

1 Answers1

3

There is a Firebase service called Cloud Functions: https://firebase.google.com/docs/functions/. You can use it to deploy your JavaScript/TypeScript functions that manipulate your realtime database.

To be able to perform what you want (resetting data daily), you need to schedule cron job that will trigger your function on Firebase periodically. To do that, please take a look at the following Firebase blog post: https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html

Ugurcan Yildirim
  • 5,973
  • 3
  • 42
  • 73