问题描述
限时送ChatGPT账号..我知道如何在 Firestore 中读取和写入文档,但是如何在不删除/删除的情况下更新 () Maps 数组中的和对象的值?如果需要,只需更改一个值.
I know how to READ and WRITE a document in Firestore, But how does one update() a Value of and object in an array of Maps without removing/deleteing? Just changing one value if needed.
我有一个包含 FormArray 的表单,当价目表有更新时,它可以编辑为一个.
I have a Form that includes a FormArray, that are able to edit as an when there is an update on the price list.
product = {
id: "product id",
brand: "Brand Name",
model: "This is the model of the brand"
lists: [
{ location: "Location 1", price: "0.00" },
{ location: "Location 2", price: "0.00" }
]
}
组件.ts
export class PageComponent implements OnInit {
productDoc: AngularFirestoreDocument<Product>;
product: Observable<any>;
}
constructor(private afs: AngularFirestore) {}
update() {
this.productDoc.update({ amount: this.updatedProduct });
}
感谢照亮它,谢谢!
推荐答案
无法更改数组中的值.您将要么删除旧的值组合并添加新的组合,或必须:
There is no way to change a value in an array. You'll either have to remove the old combination of values and add the new combination, or have to:
阅读文档.从该文档中获取整个数组.修改应用程序代码中的数组.将修改后的数组完整写回数据库.这篇关于如何在 Angular 或 Angularfirestore 中的 Firestore 上更新()一组地图对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论