Cloud Features for Firebase - Multiplayer Update

Using cloud functionality for Firebase is the best way to trigger an update of multiple locations in a hierarchy? My main goal is to update the value for all users in the list. I have created the following example that works, but I want to confirm that this is the correct way.

Database Hierarchy: Database Structure

This function starts based on update and then updates the 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 val1, val2, val3 to true as expected.

Is this the correct approach and is it guaranteed to be transactional? those. is it possible that only val1 gets updated and the rest fail?

+3
firebase google-cloud-functions


source to share


No one has answered this question yet

Check out similar questions:

4
how to update value in firebase realtime database using cloud functions for firebase
2
Restrict write access in Firebase rules to cloud features
2
Firebase Features: Ensuring Event Firing Order
2
How to redo a Cloud Firestore transaction in a cloud function to state == true
1
Firebase cloud functions for Firestore not starting
1
Cloud functions for Firebase - updating a value at a specific time of day, every day
0
How to use trasaction together with onWrite or onUpdate method in firebase cloud function?
0
Firebase cloud security feature does not start when deleting a transaction
0
Firebase Cloud works with Android app notifications
-1
Node.js - Firebase Function Database onCreate not triggering



All Articles
Loading...
X
Show
Funny
Dev
Pics