angular - 如何在firebase实时数据库中设置数据值?
问题描述
我尝试刷新数据库中变量的值。但是.set()
函数需要两个参数,我不明白第一个是什么。
我尝试使用该.push()
功能,但这会在我的数据库中创建一个新行。我不想要那个。我想要改变价值。
所以我知道我需要使用该.set()
函数,但她需要两个参数项:Firebase 操作和数据
第一个是什么?
this.afAuth.authState.subscribe(data => { // ajoute des tacoPoint
this.test = this.afDatabase.list(`TacoPoint/${data.uid}`).valueChanges();
this.test.forEach(data => { // ajoute des tacoPoint
data.forEach(e => {
e.Tacopoint = e.Tacopoint + 20;
console.log(e);
})
})
})
this.afAuth.authState.subscribe(auth => {
this.afDatabase.list(`TacoPoint/${auth.uid}`).set(); // need to set the new TacoPoint in the data base
})
解决方案
假设您要设置 object data
,
this.afDatabase.collection("TacoPoint").doc(auth.uid).set(data);
推荐阅读
- javascript - XMLHttpRequest 在中止时调用进度事件侦听器
- java - 从方法“返回”的可选 java 8
- latex - 使用便携式 miktex 配置 texmaker
- typescript - 定义符合接口 A 或 B 的类型
- amazon-web-services - 未找到 AWS 无服务器 URL
- sql-server - MSSQL 在从表中选择时创建临时标识列
- python - 将 DataFrame 中每年的每日值与另一个特定年份的同一天数的值进行比较
- grafana - 从 InfluxDB 查询关于 Grafana 变量模板的 timeFilter 的标签
- reference - 是什么导致这个“不能借用可变”异常?
- vb.net - 如何从项目资源中打开 EXE 文件?