2

I am really confused on this. If I programitically delete all the documents from a Firestore collection, the collection itself is also deleted:

this.afs.collection(myCollecton).doc(docId).delete();

But if I delete all the documents using the Firebase console online, I don't always see the collection deleted! I literally deleted all the documents from a collection and it still was in the console. I could immediately create another document in the collection. But sometimes the collection did just go away...?!

I read through some posts like Deleting all documents in Firestore collection but have not seen anything to account for this.

Since a collection must have a document it, I guess it's inferred that deleting all of the documents would delete the collection. The delete-data documentation doesn't mention this, but even so, why do I only sometimes see the collection deleted???

Love to Code
  • 425
  • 1
  • 5
  • 16

1 Answers1

3

ARG! I figured out the what and believe I understand the why: Has to do with refreshing the browser. The way the console acts may cause confusion for new Firestore users.

Deleting all documents deletes the collection as well, but it can appear that the collection did not actually get deleted if you don't refresh the browser. I guess the collection is still deleted but if you immediately create a new document, I guess it's the same as calling:

db.collection(myCollecton).doc(docId).set(data)

and the missing collection is created? If you refresh the brwoser right after deleting the last document, then you won't see the collection.

Hopefully this may someone else's confusion if they hit this.

Love to Code
  • 425
  • 1
  • 5
  • 16