Are Firestore ids unique across the whole db [duplicate]

杀马特。学长 韩版系。学妹 提交于 2021-01-05 07:25:05

问题


What i mean- if we collect all the ids(auto-generated) from the all collections and sub-collections and etc. Will all of them unique?

What for? I'am building a new feature, where users can share their items from sub-collections, so I am not sure - can I use same id between users sub-collections.

Thanks!


回答1:


Firestore document IDs must be unique within the same collection. They can be duplicated in other collections or subcollections. You can test this for yourself by manually creating the documents and see that it works OK.

Practically speaking, all automatically generated document IDs will be unique, because they are random, and there is an astronomically low chance of two of them colliding. The client SDK generates ID with 20 characters, each allowing for all lowercase letters, all uppercase letters, and all digits. So there are a total of (26+26+10)^20 = 7.0e35 possible combinations of possible unique IDs. (That's a very large number - 7 with 35 zeroes after it.)



来源:https://stackoverflow.com/questions/54747771/are-firestore-ids-unique-across-the-whole-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!