Hello,
I am trying to delete all documents within a collection but all the documents have an auto generated ID from firebase. The docs in Firebase show only how to delete a "specific" document. How can I loop over all documents and delete them ?
func deleteAllDocuments() {
let db = Firestore.firestore()
db.collection("myEntity").document("docname").delete() { err in
if let err = err {
print("Error removing document: \(err)")
} else {
print("Document successfully removed!")
}
}
}
Thank you
sveinhal
(Svein Halvor Halvorsen)
2
You'll probably get better answers in Stack Overflow or in a dedicated Firebase community.
This forum is mostly used by people who develop and discuss the development of Swift as a programming language. And although we also discuss how to use Swift here, your question isn't so much about Swift features as it is about how to use Firebase's APIs.