聚合物2.0+;firebase can';不能正确更新
我在使用Polymer 2.0和Firebase时遇到问题。 我想用聚合物2.0+;firebase can';不能正确更新,firebase,polymer,polymer-2.x,polymerfire,Firebase,Polymer,Polymer 2.x,Polymerfire,我在使用Polymer 2.0和Firebase时遇到问题。 我想用Firebase文档将数据更新到Firebase,但当我只想更新标题时,它会销毁所有以前的数据并只保存标题 更新前的结构示例: myapp: categories: 1: logoName: test.png title: test 及之后: myapp: categories: 1: title: test
Firebase文档
将数据更新到Firebase,但当我只想更新标题时,它会销毁所有以前的数据并只保存标题
更新前的结构示例:
myapp:
categories:
1:
logoName: test.png
title: test
及之后:
myapp:
categories:
1:
title: test bis
我是否必须始终提供整个记录并仅更新我想要的字段,还是只能提供我想要更新到saveValue
的字段。
我试着只给这个领域,但它似乎不起作用
以下是我代码的一部分:
<dom-module id="categorie-form">
<template>
<firebase-document
id="document"
app-name="myapp"
data="{{categorieData}}">
</firebase-document>
<iron-form id="categorieIronForm">
<form id="categorieForm">
<label for="title">Nom de la catégorie</label>
<input type="text" name="title" id="title" value="[[name]]">
<paper-button id="validButton" on-click="_submitCategorie" raised>valider</paper-button>
</form>
</iron-form>
</template>
<script>
class CategorieForm extends Polymer.Element {
static get is () { return "categorie-form" }
static get properties () {
return {
categorieData: {
type: Object
}
}
}
_submitCategorie () {
this.categorieData = {
title: form.title.value
};
this.$.document.saveValue('/categories', key)
}
}
customElements.define(CategorieForm.is, CategorieForm);
</script>
</dom-module>
名字叫卡蒂戈里
验证
类CategorieForm扩展了Polymer.Element{
静态get是(){return“categorie form”}
静态获取属性(){
返回{
分类数据:{
类型:对象
}
}
}
_次范畴(){
this.categorieData={
标题:form.title.value
};
此.$.document.saveValue('/categories',键)
}
}
customElements.define(CategorieForm.is,CategorieForm);
谢谢试试这个:
this.$.document.saveValue('/categories/1/title', key)
它在Firebase中创建一个新行,id为
title
在categories
中使用新值更新标题,但不是设置值,而是使用id创建一个新对象,其中有一个标题,值为。我不是一个好的聚合物开发人员,我不知道,但试试这个/categories/1。title
非,错误:错误:Firebase.child失败:第一个参数是无效路径:“/categories/1.title”。路径必须是非空字符串,并且不能包含“.”、“$”、“[”或“]”
。谢谢你的帮忙