【发布时间】:2017-10-06 03:37:46
【问题描述】:
我正在使用 angularfire2 使用 ionic 测试新的 firestore,我能够按照文档列出和创建集合和文档。
这些是我用来列出文档集合的ts and html 文件。
根据github 中的文档,我可以使用AngularFirestoreDocument 中的delete() 和update() 方法,但由于我有一组文档,我需要文档路径来执行类似this.chemicalsCollection.doc('path/1).delete() 或@ 的操作987654326@.
在过去(上周)我可以这样做:
constructor(database: AngularFireDatabase) {
this.itemsRef$ = this.database.list('items');
}
deleteItem(item) {
this.itemsRef$.remove(item.$key)
}
并在 html *ngFor="let item of chemicalsRef$ | async" (click)="deleteItem(item)" 中循环 itemsRef$。索引$key 来自firebase 数据库,但如果我对firestore 执行相同操作,则对象中没有$key 或path,只有我创建的数据。
我错过了什么?如何获取文档的路径?
【问题讨论】:
标签: firebase angularfire2 google-cloud-firestore