Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

513
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda