4
votes

Hi here my database structure for posts feed. Database Structure

enter image description here

When I change the user profile picture I want to update all posts with the new image (under posts/postID/user/userID/image

If I have a ton of posts how to make it in the best way (atomaticaly)

I've try to do a query and then to update all the keys, but the query is not working on userID node.

1
In general, please post your actual firebase structure as TEXT please, no images or links. Text is searchable and if we need to use it in an answer, we can copy and paste it. You can get the text version from the Firebase console->Three dots on right->Export JSON. This is a good question. - Jay
I change the structure and didn't kept the old one. But I keep your advice in mind, thanks a lot - Thierry Zanzouri

1 Answers

1
votes

There might be a better way.

Instead of duplicating all of the user details on every post, why not store the user details (including profile pic) in a structure like

/users/userID/name
/users/userID/profileURL

and then just store the posterID in the post

You will need to make two database calls to get the data, but if you update the profile picture once, it will be retrieved correctly for all posts