Home > Software design >  how to delete document without deleting collection in firestore?
how to delete document without deleting collection in firestore?

Time:08-21

I want to create some kind of collection which cannot be deleted. The reason I made it like that is because when the document is empty my website can't do the data creation process enter image description here

is it possible to create a collection in firestore that has an empty document?

i use python firebase_admin

CodePudding user response:

In Firestore, there is no such thing as an "empty collection". Collections simply appear in the console when there is a document present, and disappear when the last document is deleted. If you want to know if a collection is "empty", then you can simply query it and check that it has 0 documents.

Ideally, your code should be robust enough to handle the possibility of a missing document, because Firestore will do nothing to stop a document from being deleted if that's what you do in the console or your code.

  • Related