Firebase provides the following transaction example in the guide :
function toggleStar(postRef, uid) { postRef.transaction(function(post) { if (post) { if (post.stars && post.stars[uid]) { post.starCount--; post.stars[uid] = null; } else { post.starCount++; if (!post.stars) { post.stars = {}; } post.stars[uid] = true; } } return post; }); }
So, the structure of the object should look something like this:
posts - postID - starCount: Int - stars - uid : Bool
I was wondering if I can still execute transactions when the structure of the object looks like this:
posts - postID - starCount: Int postStars - postID - uid : Bool
Thus, there is no need to download all the user IDs that viewed the message when you download data to display the message.
source share