因此,我尝试使用Firebase将用户信息存储在数据库中,其中包括用户的电子邮件,ID和关联的组。

每次新用户创建帐户时,其数据都会保存在父节点Managers

到目前为止,这是我的代码,

var manRef = firebase.database().ref('Managers');

function saveManage(sEmail, uid, society){

manRef.push({ ManagerID : uid, Email : sEmail, Society : society })}

对于函数saveManage中的变量是从表单上的条目中收集的,我希望能够将新条目推入节点Managers中,但是将图像中突出显示的键设置为预定义值,例如uid,以便以后我更容易引用各个条目

最佳答案

听起来您只想在预定义的位置设置()值,而不是使用push()总是会使用自己的算法来生成密钥。

manRef.child(uid).set({
        ManagerID : uid,
        Email : sEmail,
        Society : society
    })
}

07-25 22:12