In my Firebase structure I have a collection and some sub-collections within it. I would like when I delete the collection, also delete the subcollections. I'm trying to do what's in the Firebase documentation: "To delete an entire collection or subcollection in Cloud Firestore, retrieve all the documents within the collection or subcollection and delete them". But is not working. I delete the collection and the subcollection still saved. My code:
void deleteNestedSubcollections(String id) {
Future<QuerySnapshot> books = libraryCollection.document(id).collection("Books").getDocuments();
books.then((value) => value.documents.remove(value));
Future<QuerySnapshot> catalogues = libraryCollection.document(id).collection("Catalogues").getDocuments();
catalogues.then((value) => value.documents.remove(value));
}
EDIT 1