Reputation: 15
My question might be really simple but i will appreciate any help, am using java and firebase and i have a variable in the database called count == 0, i need to increment this value every day by 1, so after 30 days the variable count should be count == 30, the only trouble is making that increment programmaticaly.
Any suggestions will be highly appreciated.
Upvotes: 0
Views: 390
Reputation: 1256
A scheduled Cloud Function deployed with the Firebase CLI will be the proper way to update your data in firebase. Your can run a scheduled function which can be triggered at a specific time (everyday or week however you want) and you can update your variable in the database inside the function. Here is a sample from firebase official documentation :
exports.scheduledFunctionCrontab = functions.pubsub.schedule('5 11 * * *')
.timeZone('America/New_York') // Users can choose timezone - default is America/Los_Angeles
.onRun((context) => {
console.log('This will be run every day at 11:05 AM Eastern!');
return null;
});
Read documentation here : https://firebase.google.com/docs/functions/schedule-functions#write_a_scheduled_function
Upvotes: 1