I am working on my first project in Angular and Firebase, I'm almost done.
I have a question on deleting objects using both. I have a service that will delete an object. The object has another object inside called "picture" that has 2 properties, key: string and url: string.
I want to make sure to also delete the file from storage when that object gets delete, I found this way that works, but I don't think it's the correct way to do it, specially because I get a TS Error:
"error TS2339: Property 'picture' does not exist on type '{}'."
Can anyone help me with that? Here is my delete method:
deleteEvent(id: string) {
const obj = this.db.object(this.NODE + id);
const getPic = obj.snapshotChanges().subscribe(
(a) => {
console.log(a.payload.val());
this.storage.ref(this.NODE + a.payload.val().picture.key).delete();
}
);
return obj.remove();
}