Exploring the world of Firebase functions has been an exciting learning journey for me. This innovative feature is proving to be incredibly powerful and beneficial.
I'm eager to utilize a function that can capture a database writing event, perform a comparison with a specific database location, and then write data accordingly in another part of the database based on the result of the comparison.
Below is the Node.js code I am currently working with:
exports.verificaFineLavoro = functions.database.ref('/Aziende/{nomeazienda}/LogAsegno/{pushidbracciante}/{pushidlog}/Asegno')
.onWrite(event => {
const original = event.data.val();
console.log('VerificaFineLavoro', event.params.pushId, original);
const aSegno = original;
console.log('aSegno', aSegno +"");
const FineLavoro = ref.parent.parent.parent.parent.child("Asegno/"+aSegno+"/FineLavoro");
return event.data.ref.child('FL').set(FineLavoro);
});
Although the function is successfully triggered, it encounters issues due to potentially incorrect references.