简体   繁体   English

要在Firestore DB中使用Firebase UID或令牌?

[英]To Firebase UID or Token in Firestore DB?

I understand that if I was using my own app server, I should use Token ID as a reference to the user. 我了解,如果我使用自己的应用程序服务器,则应使用令牌ID作为对用户的引用。

If I am using Firestore DB, and to refer to that user's document are based on the UID - will that cause any issue? 如果我使用的是Firestore DB,并且要引用该用户的文档是基于UID的,那会引起任何问题吗?

For example, with a database structure like this: Main -> xkljVWSjaDFAXsdSFkjsdf (UID) -> .....etc 例如,使用这样的数据库结构:Main-> xkljVWSjaDFAXsdSFkjsdf(UID)-> ..... etc

Or would it be better to use the Token ID as a reference? 还是将令牌ID用作参考会更好?

Is this the "correct" way? 这是“正确”的方式吗?

I'm already used firebase realtime database on my many projects. 我已经在许多项目中使用了Firebase实时数据库

You can store your users data via this structure: 您可以通过以下结构存储用户数据:

Main -> Users -> xkljVWSjaDFAXsdSFkjsdf (UID) -> ...

And you can access those data easily and your UID will be always unique . 而且您可以轻松访问这些数据,并且您的UID将始终是唯一的

String UID = FirebaseAuth.getInstance().getCurrentUser().getUid();

There will be no issue by using UID. 使用UID不会有问题。

Refarence Firebase Data Modele Refarence Firebase数据模型

Happy Programming. 编程愉快。

Or would it be better to use the Token ID as a reference? 还是将令牌ID用作参考会更好?

It won't. 不会的 Using the uid is the best practice when it comes to Firebase. 对于Firebase,使用uid是最佳实践。

You can get the uid using the following line of code: 您可以使用以下代码行获取uid:

String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();

The token id can be different while the uid is always the same. 令牌ID可以不同,而uid始终相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM