Is It Possible To Receive Duplicate Ids With Firebase .doc()?
As specified in the Firebase documentation, .doc() creates a unique ID. I create new documents for Firestore the following way (note that session.docId should be equal to the actua
Solution 1:
doc()
always generates a DocumentReference with random ID immediately on the client app (not asynchronously) that is virtually guaranteed to be unique. The chance of collision between two IDs is astronomically low. It's effectively the same thing as calling add()
, except it is not actually creating the document at the same time.
Note that doc()
doesn't return the string ID directly - it returns a DocumentReference that contains the ID.
See also:
If for some reason you do not trust this method of generating IDs, you are free to generate them yourself somehow. It's just a string.
Post a Comment for "Is It Possible To Receive Duplicate Ids With Firebase .doc()?"