Performing transactions of fanned-out data in Firebase
<p>I am working on creating a social network-esque feed, and have been following the <a href="https://firebase.googleblog.com/2015/10/client-side-fan-out-for-data-consistency_73.html" rel="nofollow">guide</a> on the Firebase blog on fanning out my "blog posts" across the database.</p>

<p>This makes sense and works well for interacting with these posts using the update() method. However, it is unclear to me how I could go about performing transactions atomically in multiple places.</p>

<p>For example, I want to add the ability to 'like' a post. If I were to have that post in one location, my code would look like so:</p>

<pre><code>var postRef = firebaseDB.ref("posts/" + postID + "/likes");
postRef.transaction(function(likes) {
    return (likes || 0) + 1;
});
</code></pre>

<p>For obvious reasons, the solution below is <strong>not</strong> atomic.</p>

<pre><code>var postRef1 = firebaseDB.ref("posts/" + postID + "/likes");
postRef1.transaction(function(likes) {
    return (likes || 0) + 1;
});

var postRef2 = firebaseDB.ref("user/" + userID + "/posts/" + postID + "/likes");
postRef2.transaction(function(likes) {
    return (likes || 0) + 1;
});
</code></pre>

<p>Since transaction operates on a ref, how can I "like" the posts in multiple places atomically?</p>