Using Cloud Functions for Firebase, what is the best way to trigger an update of multiple locations in the hierarchy? My main goal is to update a value for all users in a list. I created the following example, which works, but I want to confirm that it is the proper way.
Database Hierarchy: Database-Structure
This function triggers based off an update and then updates a list of other nodes:
exports.multiLocationUpdateTest = functions.database.ref('/atest/update').onWrite(event => {
console.log('here');
var mergedUpdate = {};
mergedUpdate[ 'list/item1/val1' ] = true;
mergedUpdate[ 'list/item2/val2' ] = true;
mergedUpdate[ 'list/item3/val3' ] = true;
return event.data.ref.parent.update(mergedUpdate);
});
It will update each of the val1, val2, val3 to true, as expected.
Is this the correct approach and is this guaranteed to be transactional? i.e. is it possible that only val1 gets updated and the others fail?