【发布时间】:2021-09-04 14:19:50
【问题描述】:
我的系统的主要目标是在经过身份验证的用户更改或重命名他或她的帐户名称时更新在我的论坛上发帖的用户的名称。
整个过程没有错误,但不幸的是,在论坛发帖的其他用户也更新了他们的名字。
所以这是输出:
我尝试以下方法:
- 我使用 Firebase 中的 WHERE 函数来过滤用户发布的帖子(登录用户本身)。不知道为什么整个过程都失败了。
这是sn-p代码。
async updateAll(username) {
const batch = this.afs.firestore.batch();
// cUser is the USER ID
const userRef = this.afs
.collection('post', (ref) => ref.where('postedById', '==', this.cUser))
.ref.get();
(await userRef).forEach((element) => {
batch.update(element.ref, {
postedBy: username,
});
});
return batch.commit();
}
【问题讨论】:
标签: javascript firebase google-cloud-firestore angularfire2