【发布时间】:2018-06-07 02:45:24
【问题描述】:
我正在更新单个字段名称,即“名称”,我成功编辑它,但它创建了另一个节点。像这样
这是我的代码:
const user = firebase.auth().currentUser;
let uid;
if (user != null) {
uid = user.uid;
const db = firebase.firestore();
const docRef = db.collection('users').doc(uid);
docRef.update({
name,
timestamp: firebase.firestore.FieldValue.serverTimestamp()
}).then(() => {
console.log('Profile Successfully Edited!');
}).catch((error) => {
console.log('Error updating the document:', error);
})
}
【问题讨论】:
-
名字是什么?更新中
-
是我要更新的字段名。
标签: javascript firebase react-native google-cloud-firestore