I am building a firebase web application. Here is a simplified Firestore structure:
...
- ...
ITEMS
- item1
PHOTOS
- photo1
uid
VIDEOS
- item2
USERS
- uid1
displayName
...
- uid2
- ...
When someone accesses a photo or video I want to display the appropriate displayName and profilePhoto for that item.
I see two possible solutions:
Store only user UID in items. On every load, get user data from USERS collection or Then loop in user's UIDs and connect them with item UIDs. This would be done on every call. When users update displayName or profilePhoto, there wouldn't be any problem.
Store user UID, displayName, and profilePhoto path on the item. When users update data I would need to run a cloud function which would then update all items with new data.
How should I approach this and is there any other approach that I should consider? I lean towards the second solution.