0

I have an app which is connected on a Firebase Realtime Database. This app deal with a lot of data so i would like to cleanup the old data every 24h. So, what is the best solution to achieve this ? I heard of Google Cloud Scheduler or App Engine Cron

ps : I already tried Firebase Cloud Function Triggers (onCreate, onWrite), but there is too much data in the database, and the trigger quickly reach the max query limit.

Thanks

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
gsoulie
  • 25
  • 1
  • 7
  • The most common solution is to have a periodic process (such as in a Cloud Function) clean up the outdated data, as shown here: https://stackoverflow.com/a/32012520. If that is too much data, you might want to run the clean up more frequently. If that doesn't work for you either, you'll have to share more details about the actual data, and the code you tried, for us to be able to help. I highly recommend reading [how to create a minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) in that case. – Frank van Puffelen Mar 04 '19 at 15:20
  • I already tested that snippet, it works well but each time you make an `updates[child.key] = null` it seems that the function is triggered again etc... To go further, my app is an assets tracker (working with BLE sensors), and data are send to Firebase every minutes (this period is customizable to 1min, 5min, 10min, 20min, 1hour). I work with potentially 20 to 50 sensors at the same times (so i can send 20 to 50 data every minutes). So the Firebase Cloud Function could be triggered 50 times in one call. With a free acount the limit is quickly reached – gsoulie Mar 04 '19 at 16:00
  • You can also turn the same code into a periodic function, so that it runs every hour or so. See https://stackoverflow.com/a/42796988 – Frank van Puffelen Mar 04 '19 at 16:47

0 Answers0