2

I just changed my code as below and it is working. Bulk delete is possible in google cloud-firestore.

async deleteMembersOfGroup(clubId: string, groupId: string) {
    //path of the collection
    const path = "club/" + clubId + "/group/" + groupId + "/group-members";

//query snapshot
    const qry: firebase.firestore.QuerySnapshot = await this.afs.collection(path).ref.get();

    const batch = this.afs.firestore.batch();

//looping through docs in the collection to delete docs as a bulk operation
    qry.forEach(doc => {
      console.log('deleting....', doc.id);
      batch.delete(doc.ref);
    });

//finally commit
    batch.commit().then(res => console.log('committed batch.'))
    .catch(err => console.error('error committing batch.', err));
  }
Damith_009
  • 23
  • 5
  • Functionality to delete an entire collection is not built into the SDKs at the moment. See https://stackoverflow.com/questions/46692845/why-single-bulk-delete-collection-in-cloud-firestore-is-not-possible-like-it-i – Frank van Puffelen Mar 28 '18 at 13:48
  • Possible duplicate of [Why "single bulk" delete collection in Cloud Firestore is not possible like it is with Realtime Database?](https://stackoverflow.com/questions/46692845/why-single-bulk-delete-collection-in-cloud-firestore-is-not-possible-like-it-i) – Frank van Puffelen Mar 28 '18 at 13:48

0 Answers0