Javascript 数据库中的Firebase-update()值
我正在尝试Javascript 数据库中的Firebase-update()值,javascript,angular,firebase,firebase-realtime-database,Javascript,Angular,Firebase,Firebase Realtime Database,我正在尝试update()firebase数据库中的一个值,但我正在努力 我首先做了: this.database.list('/replies/'+this.postData.parent+'/'+this.postData.id).update('score', this.voteCount) 我以为这样行得通,但我犯了一个错误: 错误:Reference.update失败:第一个参数必须是包含要替换的子对象的对象 然后我试着: this.database.list('/replies
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})
此.voteCount
为整数
我得到了以下错误:
错误:需要字符串、快照或引用。格特:反对
我真的很困惑,为什么它先要一个对象,然后告诉我它不想要对象
如果我将update()
更改为set()
,并将其保持为('score',this.voteCount)
它工作正常,但我不想设置它,如果它存在,我想更新它
我做错什么了吗?谢谢大家! 试试看:
this.database.ref('/replies/'+this.postData.parent+'/'+this.postData.id).update({'score': this.voteCount})
尝试:
是的,谢谢你,这很有效。对我来说,我必须做
这个.database.database.ref
。谢谢你!是的,谢谢你,这很有效。对我来说,我必须做这个.database.database.ref
。谢谢你!