I can delete all documents in firestore one by one. But is there any efficient way to delete entire collection/batch, because one by one takes ages. Working but slow code:
public async Task DeleteCollection(string collectionReference)
{
CollectionReference collection = db.Collection(collectionReference);
QuerySnapshot snapshot = await collection.GetSnapshotAsync();
IReadOnlyList<DocumentSnapshot> documents = snapshot.Documents;
while (documents.Count > 0)
{
foreach (DocumentSnapshot document in documents)
{
Console.WriteLine("Deleting document {0}", document.Id);
await document.Reference.DeleteAsync();
}
snapshot = await collection.GetSnapshotAsync();
documents = snapshot.Documents;
}
Console.WriteLine("Finished deleting all documents from the collection.");
}