I'm trying to use Angularfire2 in an Angular 4 app. I am able to get a collection of objects from my firestore using the AngularFirestoreCollection. However, when I iterate through the documents in the collection I have noticed that the documents do not contain the document key. So, I don't think I have any way to do stuff like delete a document from the list in the UI since I don't know the key associated with the document. Here is my code:
export class CategoryComponent implements OnInit {
private categoryCollection: AngularFirestoreCollection<any>;
public categories: Observable<any[]>;
public category: Category;
constructor(public db: AngularFirestore, private router: Router) {
this.categoryCollection = db.collection<any>('categories');
this.categories = this.categoryCollection.valueChanges();
this.category = new Category();
}
}
That code gets me a collection that looks like this:
{name: 'Some name'}
Where I would expect something more like:
{key: 'theKey', name: 'Some name'}
I keep looking at the docs on github, but I am either blind, or the docs don't show what I am doing wrong. Maybe I am just ignorant as to how firebase sends documents back in a collection?