auth.onAuthStateChanged(function(user){
if(user.uid){
var db = firebase.firestore();
document.getElementById("empUpd_email").value = user.email;
db.collection("employee").doc(user.uid).get().then(result => {
console.log(`${result.id} => ${result.data()}`);
document.getElementById('empUpd_fullname')。value = result.fullName;
});
}else{
//no user is signed in
}
});**strong text**
我想获得性别价值
数据库看起来像
地址 “阿卜杜勒” (串) 生物 “阿卜杜勒” 多宝 “ 2020-08-22” 全名 “阿卜杜勒” 性别 “女” 服务名 “阿卜杜勒”
答案 0 :(得分:1)
您可以使用对gender
进行操作的相同方法来检索fullName
的值。
尝试这样的事情,
auth.onAuthStateChanged(function(user) {
if (user.uid) {
var db = firebase.firestore();
document.getElementById("empUpd_email").value = user.email;
db.collection("employee").doc(user.uid).get().then((result) => {
const results = result.data();
document.getElementById('empUpd_fullname').value = results.fullName;
document.getElementById('empUpd_gender').value = results.gender; // Tag ID is a guess!
});
} else {
//no user is signed in
}
});
希望有效!
答案 1 :(得分:0)
DocumentReference documentReference = fStore.collection("User").document(Objects.requireNonNull(fAuth.getCurrentUser()).getUid());
documentReference.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists()) {
profileName.setText(documentSnapshot.getString("Name"));
profileEmail.setText(documentSnapshot.getString("Email"));
}
}
});