0

I'm trying to delete a post and all its sub-collections. When using the code below, I'm only able to delete all the fields in the post, but NOT the sub-collections it has. I have looked at other similar posts, but I have not been able to solve this issue.

FirebaseFirestore.instance.collection('posts').doc(postId).get().then((doc) {
      if (doc.exists) {
        doc.reference.delete();
      }

What should I change to make it work? Thanks a lot!

Alvaro-99
  • 21
  • 3
  • If you disagree with why your previous post of the same problem was closed, comment there please. But I tend to agree with Doug's assessment: you'll need to write code to recursively delete the subcollections. – Frank van Puffelen Jul 13 '21 at 05:29

0 Answers0