如何在firebase中向用户添加自定义配置文件详细信息?

时间:2018-03-28 15:11:16

标签: javascript node.js firebase authentication profile

如何向firebase中的用户添加自定义配置文件详细信息?我知道我们已经可以添加displayName和photoURL,但我想添加更多字段,如年龄,性别,国家等。有什么方法可以做到吗?

user.updateProfile({
      displayName: "Jane Q. User",
      photoURL: "https://example.com/jane-q-user/profile.jpg"
    }).then(function() {
      // Update successful.
    }).catch(function(error) {
      // An error happened.
    });

1 个答案:

答案 0 :(得分:0)

您可以创建users端点并在其中存储自定义用户数据。

function writeUserData(userId, name, email, imageUrl) {
  firebase.database().ref('users/' + userId).set({
    username: name,
    email: email,
    profile_picture : imageUrl,
    // Add more stuff here
  });
}

有关详细信息,请参阅https://firebase.google.com/docs/database/web/read-and-write#basic_write