I have a firebase database, and I'm currently trying to use cloud functions to perform an operation when a value changes in my database. So far, it has successfully run the code to run when the value in my database changes. However, when the database value changes, now I need to check another value to determine its status, and then perform an action after that. The problem is that I have experience with JS ~ 0, and I have no way to debug my code other than deploying, changing the value in my database, and viewing the console log.
Is there a way to find another value in the database and read it? How to find a value and then set a value for it? Here is the code:
export.determineCompletion =
functions.database.ref('/Jobs/{pushId}/client_job_complete')
.onWrite(event => {
const status = event.data.val();
const other = functions.database.ref('/Jobs/' + event.params.pushId + '/other_job_complete');
console.log('Status', status, other);
if(status == true && **other.getValueSomehow** == true) {
return **setAnotherValue**;
}
});
This code partially works, it successfully receives the value associated with client_job_complete and saves it in status. But how do I get a different value?
Also, if anyone has any JS or firebase documentation that they think will help me, please share! I read a bunch on firebase here: https://firebase.google.com/docs/functions/database-events , but it only talks about events and very briefly
Thank you for your help!
source
share