0

When i delete a document containing sub collections firebase leaves the document id greyed out and It seems not deleted from the console. Tho it does not exist in snapshots. Have i deleted the data from the database wrong? (using flutter) database in console

code for deleting document but the subcollections are still there

Future<bool> deleteWorkout(String _id) async {
    try {
      await _db.collection(WORKOUTS_COLLECTION).doc(_id).delete();
      return true;
    } catch (e) {
      return false;
    }
  }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

If the document you deleted still has subcollections, it shows as greyed out and italic in the Firebase console. This is so that you can still navigate to the subcollections of the (now non-existing) document path.

If you want to delete both the document and its subcollections, be sure to perform a recursive delete.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Okay, thank you. But would it matter that these subcollections are there? Should i delete them recursively, and if so how would i do this in flutter – Mathias Frihauge Aug 08 '22 at 22:48
  • Only you can determine if it matter. But if you don't use the data in them, you still pay for their storage. --- For deleting them: https://stackoverflow.com/questions/48137582/firestore-db-documents-shown-in-italics and probably more from here: https://www.google.com/search?q=firestore+delete+cursive+document+id – Frank van Puffelen Aug 08 '22 at 22:55