When a user wants to delete their account, I need to ensure that the 'documents' they created in Firebase are deleted as well.
After some research online, I came across the following code snippet:
deleteAccount() {
const qry: firebase.firestore.QuerySnapshot = await this.afs.collection('houses', ref => ref.where('email', '==', this.auth.currentUser.email)).ref.get();
const batch = this.afs.firestore.batch();
qry.forEach( doc => {
batch.delete(doc.ref);
});
batch.commit();
}
However, I encountered an error with the 'await' keyword stating:
'await' expression is only allowed within an async function.
Can anyone suggest a solution to this issue or recommend a better approach? I'm new to this and would appreciate any guidance you can provide.