【发布时间】:2018-03-12 00:55:34
【问题描述】:
我正在尝试 update() 我的 firebase 数据库中的一个值,但我很挣扎。
我第一次这样做:
this.database.list('/replies/'+this.postData.parent+'/'+this.postData.id).update('score', this.voteCount)
认为这会起作用,但我得到了一个错误:
错误错误:Reference.update 失败:第一个参数必须是包含要替换的子对象的对象。
然后我尝试了:
this.database.list('/replies/'+this.postData.parent+'/'+this.postData.id).update({'score': this.voteCount})
this.voteCount 是一个整数。
我收到以下错误:
ERROR 错误:需要字符串、快照或引用。得到:对象
我真的很困惑为什么它首先要一个对象,然后告诉我它不想要一个对象..
如果我将update() 更改为set() 并保持为('score', this.voteCount),它可以正常工作,但我不想设置它,如果它存在我想更新它..
我做错了吗?谢谢!
【问题讨论】:
标签: javascript angular firebase firebase-realtime-database