I tried several methods, but when I actually click the delete button, not just one document is deleted, but all the documents. What should I do? Here's the code:
const db = firebase.firestore();
db.collection('data').get().then((snapshot)=>{
snapshot.forEach((doc)=>{
const da = doc.id;
function delei(){
db.collection('data').doc(da).delete().then(()=>{
console.log('deleted');
})
}
var 템플릿 = `<div class="attend">
<div class="date">${doc.data().날짜}</div>
<div class="icons">
<span class="download 48dp material-icons-outlined" onclick="location.href='${doc.data().엑셀}'">file_download</span>
<span class="trash 48dp material-icons-outlined" onclick="${delei()}" >delete</span>
</div>
</div>`
$('.big').append(템플릿);
})
});
thank you
I hope you are doing great. I will share with you two links to a beautiful tutorial about your question from YouTube. For firebase v9: https://www.youtube.com/watch?v=s1frrNxq4js For earlier version (like yours): https://www.youtube.com/watch?v=UZqXcoqC95E&list=PL4cUxeGkcC9itfjle0ji1xOZ2cjRGY_WB&index=5 I'm sorry that I didn't write the code but I saw your question and I was so tired, and I wanted to help with anything useful.