我似乎无法弄清楚如何更新数据库中的数据:
这是代码:
handleSubmit(event) {
event.preventDefault();
var fulladdress = this.state.address1 +" "+ this.state.city +", "+ this.state.state +" "+ this.state.zip;
Geocoder.getFromLocation(fulladdress).then(
json => {
var location = json.results[0].geometry.location;
//alert(location.lat + ", " + location.lng);
var geo = new db.GeoPoint(location.lat, location.lng)
var updatecompany = new db.Companies({
id: '16747fce-f0b1-422b-aa60-220c2dccac58',
name: this.state.name,
logo: '',
photo: '',
address1: this.state.address1,
address2: this.state.address2,
city: this.state.city,
state: this.state.state,
zip: this.state.zip,
geo: geo,
});
updatecompany.update().then(() => {
alert("company saved!")
})
},
error => {
alert(error);
}
);
}
在此文件中,我希望更新公司资料的数据。首先,我们从 Google Maps API 获取纬度/经度。
当我运行它时,我收到此错误:未处理的拒绝(EntityExistsError):实体/db/Companies/16747fce-f0b1-422b-aa60-220c2dccac58 由不同的数据库管理。
我尝试删除 ID,但随后出现此错误:未处理的拒绝(PersistentError):无法插入新对象。
我需要使用密钥或其他东西吗?或者 id 是在对象之外传递的还是什么?