Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

514
Visualizações
Firebase Firestore deleteDoc() not working

I am working on my first Web App using firebase and I have hit a problem I can't find the solution to. I am trying to delete a document by Id, The function works fine however the document is not deleted. I have set the Firestore rules to allow delete as well. However it's still not working. I'll leave the relevant code and rules here:

Code

function del(x){
      console.log("Delete File : "+filesListID[x-1]);
      console.log("File : "+fileList[x-1].fileno + " " +decrypt(fileList[x-1].fileno));
      deleteDoc(doc(firestore,"property",filesListID[x])).then( function(){
          var table = document.getElementById("userlist");
          table.innerHTML = "";
          userList();
          alert("File Deleted Successfully");
      }).catch((error) => {
        console.log("Error Deleting Property List: "+error);
      });
      
}

Rules

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write, delete: if request.auth != null;
    }
  }
}

I can't figure out what's going wrong here, any suggestions will be helpful, Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I believe you want to delete filesListID [x-1] but inside deleteDoc() you have mentioned filesListID [x]. And at the top of that, before deleting, you could also check if filesListID [x-1] exists or not.

function del(x) {
  console.log("Delete File : " + filesListID[x - 1]);
  console.log("File : " + fileList[x - 1].fileno + " " + decrypt(fileList[x - 1].fileno));
  deleteDoc(doc(firestore, "property", filesListID[x - 1])).then(function() {
    var table = document.getElementById("userlist");
    table.innerHTML = "";
    userList();
    alert("File Deleted Successfully");
  }).catch((error) => {
    console.log("Error Deleting Property List: " + error);
  });
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda