【发布时间】:2020-06-19 23:00:13
【问题描述】:
async incrementTuts(key) {
let newData= {'tutsApplied':this.tutsApplied+1}
let newInfo = firebase.database().ref('thisis/'+this.route.snapshot.paramMap.get('key')).update(newData);
}
我想使用 ionic 4 在 firebase 实时数据库上增加 tutsApplied。我该如何实现。
更正的图像:
更新:
我用过
let key = this.route.snapshot.paramMap.get('key');
let ref = firebase.database().ref(`thisis/${key}/tutsApplied`);
ref.transaction((current) => {
return (current || 0) + 1;
});
但新字段是在未定义下创建的,如图所示。我不想创建新领域。以及如何在控制台中打印当前值?
【问题讨论】:
-
你现在得到了什么?
-
好吧,当 Firebase 中的实际子名称为
tusApplied时,该代码将无法工作,因为它试图访问tutsApplied
标签: javascript firebase ionic-framework firebase-realtime-database