Im currently working on a project and I want to give percentage of points to every users daily based on their current points available and update the user data in my firebase database. I wanted to add points for my users on a daily basis using firebase functions.
I've looked up several guides on setting up Firebase Functions and right now I'm just not sure how can i update the data.
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp;
export const helloWorld = functions.https.onRequest(async(request, response) => {
await updatePoints();
response.send("Hello from Firebase!")
});
export async function updatePoints(){
try{
const db = admin.database();
const ref = db.ref("Users/{userId}")
await ref.update({
"points": "3000"
});
}
catch(err){
console.log("Error occured:"+err)
}
}