I am developing some codes using Flutter. It's an e-commerce app. There will be a comment section for products. When a user commented, its user id (uid) is stored in "comments" collection. Then, it should be showed as user display name, below the comment.
I am trying to access FirabaseUser by using its UID. So, I can get the display name.
How can I do that?
The following samples are for "current user".
https://firebase.google.com/docs/auth/web/manage-users#get_a_users_profile
We chose to store all that kind of references (foreign keys in Relational Databases) as a shallow object in our documents like this:
...
creator: {
ref: 'users/xxxxx',
label: 'John Doe'
}
...
This way, we avoid making multiple queries for records with multiple references while preserving the link to the original referenced record.
This is no magic bullet since the value stored as label here could evolve over time but one can develop cloud functions to regularly take care of that.