小编imc*_*ean的帖子

如何在 Angular 或 Angularfirestore 中的 Firestore 上更新()一组地图对象?

我知道如何在 Firestore 中读取和写入文档,但是如何在不删除/删除的情况下更新()地图数组中的值和对象?如果需要,只需更改一个值。

我有一个包含 FormArray 的表单,可以在价目表上有更新时进行编辑。

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" }
  ]
}
Run Code Online (Sandbox Code Playgroud)

组件.ts

    export class PageComponent implements OnInit {
      productDoc: AngularFirestoreDocument<Product>;
      product: Observable<any>;
    }

constructor(private afs: AngularFirestore) {}

  update() {
    this.productDoc.update({ amount: this.updatedProduct });
  }
Run Code Online (Sandbox Code Playgroud)

感谢您照亮它,谢谢!

javascript firebase angularfire angular google-cloud-firestore

3
推荐指数
1
解决办法
624
查看次数