How do you delete data in Firestore?

Answer

Deleting data in Firestore: (1) Delete a documentawait deleteDoc(doc(db, "users", "alice")). Note: deleting a document does NOT delete its subcollections; they become orphaned but accessible via their direct path; (2) Delete a fieldawait updateDoc(ref, { fieldToDelete: deleteField() }). The deleteField() sentinel marks the field for removal; (3) Delete a collection — Firestore has no built-in operation to delete entire collections. You must query all documents and delete them in batches. For large collections, use the Firebase Admin SDK with a server-side script or Cloud Functions; (4) Delete array elementawait updateDoc(ref, { tags: arrayRemove("oldTag") }); (5) Batch delete — use writeBatch() to delete multiple documents atomically (max 500 operations per batch). Important: never delete large collections from the client — use server-side batch deletion with pagination to handle collections of any size.