I'm having a time trying to wrap my head around what I thought was a simple concept.
I have an app where I sign up a user, allow that user to set a 'photoURL' to their 'user' information in the Firebase Auth system. This works. When the user creates a post in my app, I want to display the title, image and 'photoURL' of the creator.
Currently, I save the post:
-Post {
-id
-title
-image
-photoURL <- from current logged in user }
I also allow users to visit the posters page via routing /poster/'displayName'
So later, when a user updates their profile information like displayName or photoURL, do I need to go find all posts, comments, messages, replies and any other place that this user has a record and update the photoURL?
What I thought I would be able to do is say: (pseudo code)
get all posts =>
foreach(post)
post = {
title: post.title.val()
image: post.image.val()
avatar: firebase.database().ref().child('users' + post.key)
}
Everything I read says I need to store that photoURL in my own 'Users' table. If I do that, then none of the posts get updated unless I write a server call to do that every time there is a change. Problem is, if I have 100K users, and 10% of them change their photoURL, I then have to change it in posts, comments, replies and messages per user. If the average user has 100 posts, 4000 comments, 6000 replies, we're looking at about 10K places * 10K users that have to be updated and if the average server call is 137ms, then my costs are around $175 (costs)
The other option is to pull information from two tables and create a new object every time. This would lead to about double the server calls and time thus doubling my costs.
Is this the best approach for this? I thought this would be a lot easier to just get the user photo and display name.
Sorry for the epic long post but I'm trying to learn. Thanks all!