Reputation: 181
Im trying to delete a document X in collection Users but in this collection, there is another collection tasks is the collection Users. How can I delete all the data in the document X (includes collection tasks)
firebase.firestore().collection("Users").doc(X).delete();
Upvotes: 0
Views: 28
Reputation: 598728
There is no single operation in the API to delete an entire collection. Instead a collection comes into existence once a first document is added to it, and a collection disappears once the final document is deleted from it.
This means that you'll need to delete each document in the collection individually, preferably using batch delete operations. Once you've deleted the last document from the subcollection, the collection itself is also gone.
Upvotes: 2