How I get the generated document ID of a collection in Firestore?
If you want to get the id of a Firestore doc, call doc.id. This is not in doc.data and confused me as well.
doc.id
doc.data
const docs = await getDocs(collection(db, 'collection_name')); docs.forEach((doc) => { console.log(doc.id); });