数据库设计 – Firebase:设置其他用户属性

我想添加一个属性到Firebase用户对象. user documentation表示,我只能使用Firebase实时数据库存储其他属性.

我不确定这在实践中如何运作.

以下是什么意思在实践中?

You cannot add other properties to the Firebase User object directly;
instead,you can store the additional properties in your Firebase
Realtime Database.

我解释如下:

“您不能修改FIRUser对象的属性,但您可以将其与其他对象组合”

我找到了这样我设置的设置功能documentation

var userRef = ref.child("users");
  userRef.set({
    newfield: "value"
  });

这是一个明智的做法吗?

解决方法

你几乎在那里在传统Firebase文档中,我们在 storing such additional user data上有一节.

关键是在用户的uid下存储附加信息:

let newUser = [
        "provider": authData.provider,"displayName": authData.providerData["displayName"] as? Nsstring as? String
    ]
    // Create a child path with a key set to the uid underneath the "users" node
    // This creates a URL path like the following:
    //  - https://<YOUR-FIREBASE-APP>.firebaseio.com/users/<uid>
    ref.childByAppendingPath("users")
       .childByAppendingPath(authData.uid).setValue(newUser)

添加一个注释,我们应该在新的文档中添加这些信息.我们只需要找到一个很好的地方.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 &#39;EastRiver&#39; 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...