Reputation: 334
I noticed that when creating a new document(new user) in Cloud Firestore, Firestore will randomly assign an id. Should I instead set this Document to the manually generated User UID? If not, how do I reference the randomly generated Firestore Document Id when updating the fields in said document?
Upvotes: 0
Views: 453
Reputation: 598740
There is no single correct answer here, but most apps use the UID of the user as the document ID for that user's profile in a users
collection.
One reason for this is that it allows a direct lookup of the user's profile document based on their UID, which is typically the most common way of identifying a user in an app.
Using the UID as the document ID also ensures that you can only have a single profile document per UID, which is a common requirement.
Upvotes: 1