Deleting Data (Delete)
deleteDoc removes a document entirely. Since a delete action can be irreversible, it's good practice to add a user confirmation step. Rather than deleting the moment someone taps the "Delete" button, add a confirm dialog. The database won't shed a tear over a misclick, but your user might.
Code Example
javascript
import { getFirestore, doc, deleteDoc } from 'firebase/firestore';
const db = getFirestore();
async function deleteNote(noteId) {
const isConfirmed = window.confirm('ဒီ note ကို ဖျက်မှာ သေချာလား?');
if (!isConfirmed) return;
await deleteDoc(doc(db, 'notes', noteId));
console.log('Note deleted');
}Watch out for subcollections
Deleting a document does not automatically delete its subcollections underneath it. If you have nested data, plan out your delete strategy carefully.
Best practice
For production apps, it's often better to do a soft delete — adding a deletedAt field instead of hard-deleting. That way you can restore it later if needed.