// round page
newRound() {
console.log('new round ', this.round);
this.you.score = +this.score;
this.round++;
console.log('THE PLAYERS -> ', this.players);
this.afStore.collection('matches').doc(this.gameRoom).collection('match').doc(`${this.round}`).set({players: this.players, round: this.round}).then(() => {
console.log('UPDATED GAME');
});
this.router.navigate(['/events/tab2/' + this.gameRoom]);
}
// Tab page that goes to the round page
// NOTE: this is for the next page, round 1,2,3,4 etc...
theRound() {
this.newRound++;
console.log('this is the new round ', this.newRound);
this.afStore.collection('matches').doc(this.gameRoom).collection('match').doc(`${this.newRound}`).set({players: this.players, round: this.newRound});
this.afStore.collection('matches').doc(this.gameRoom).collection('match').doc(`${this.newRound}`).valueChanges().subscribe((v: any) => {
this.router.navigate(['/events/tab2/' + this.gameRoom + '/' + v.round]);
console.log('data returned from firebase ', v);
});
}
大家好!我有一个问题。我遇到了一个问题。我试图在firebase中更新一个特定的集合,但它创建了这个集合,但当我在圆形页面中按下一个值时,它没有更新 "分数"。另外,它还创建了第二个有更新分数的集合。如果有任何帮助,我将非常感激。
好吧,你更新了你的文档 set()
和firebase文档说。
如果文档不存在,就会被创建。如果文档确实存在,它的内容将被新提供的数据覆盖,除非你指定这些数据应该被合并到现有的文档中去
但在更新之前,你要对 this.newRound
因此,你的文档是一个增量,firebase会创建一个新的文档。