我创建了以下数据库:
db.collection('users').doc(usercred.user.uid).set({
"uid": usercred.user.uid,
"phone": usercred.user.phoneNumber,
"active-image-size-limit": 1500,
"credits": 10,
"active-temp": temName
});
如何访问特定的“活动温度”字段?
答案 0 :(得分:1)
要检索active-temp
,请执行以下操作:
var docRef = db.collection("users").doc(usercred.user.uid);
docRef.get().then(function(doc) {
if (doc.exists) {
console.log(doc.data()["active-temp"]);
} else {
// doc.data() will be undefined in this case
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});
doc.data()
将包含所有数据