Perform daily calculations on Vuejs app with firebase

55 Views Asked by At

I have a Vuejs app with firebase auth, firestore and vuex. I have a daily calculation in one of the components. What would be the best way to keep that calculated value valid, even if a user did not login for some time? Thanks!

1

There are 1 best solutions below

1
On

If I understand correctly, you trigger, in your Vue.js app, a calculation that saves some data in Firestore (i.e. the calculation result). So far this calculation is triggered when the user logs in to your app, but you would like to trigger it even if the user does not log in for one or more days.

One approach is to use a scheduled Cloud Function that will do the calculation in the back-end. The Cloud Function could run every day at 23:59 and check, for each user, if the daily calculation was already done (following the user login). If not, the Cloud Function executes the calculation and updates Firestore accordingly.