I'm testing the new firestore with ionic using angularfire2 and I'm able to list and create collections and documents following the documentation.
These are the ts and html file that I use in order to list a collection of documents.
According to the documentation in github I can use the delete() and update() methods in AngularFirestoreDocument
but since I have a collection of documents I need the document path to do something like this this.chemicalsCollection.doc('path/1).delete()
or this.chemicalsCollection.doc('path/1).update()
.
In the old days (last week) I could do something like this:
constructor(database: AngularFireDatabase) {
this.itemsRef$ = this.database.list('items');
}
deleteItem(item) {
this.itemsRef$.remove(item.$key)
}
and loop itemsRef$
in the html *ngFor="let item of chemicalsRef$ | async" (click)="deleteItem(item)"
. The index $key
came from the firebase database but if I do the same with firestore there's no $key
or path
in the object, just the data I created.
What am I missing? how do I get the document's path?