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

350
Vistas
Firebase Error: TypeError: Cannot use 'in' operator to search for '_delegate' in undefined

I'm new to firebase and have been having some difficulties over the past two days with querying and deleting documents from a collection. Specifically, I am trying to clear my entire collection of company dummy data each time I start the server before I loop over the dummy data and write it to the collection (to prevent duplication).

I have been able to take my company dummy data and write it to my 'companies' collection no problem. The problem is when I attempt to delete a doc from the collection; it does not delete and appears to throw the following error when passing the retrieve variable to the deleteDoc() method.

Note: I decided to try deleting just one doc first. If I can do that successfully and it is reflected in the firebase collection, then I should be able to clear the whole collection with no problem.

TypeError: Cannot use 'in' operator to search for '_delegate' in undefined

I understand that the 'in' keyword is only valid when checking if a property exists on an object. I logged the data at each point of the function to make sure I was referencing the doc correctly and passing the appropriate data type to the deleteDoc() function (which would be an object).

Here is my code for writing the dummy data to the database (works fine):

export const dummyDataToFirebase = async() => {
  try {
    const batch = writeBatch(db);
    dummyData.forEach(doc => {
      addDoc(companyRef, doc)
      console.log(doc)
    })
    await batch.commit();
    console.log('success!')

  } catch (error) {
    console.error(error, 'try again!');
  }
} 

Here is my code for deleting a doc from the database collection (problem)

const deleteOne = async () => {
  try {
    const docRef = doc(companyRef, '86e9cade14e2a972c526db4b7c828ed7')
    const retrieve = await getDoc(docRef)
    console.log(retrieve)
    await deleteDoc(retrieve)
    if(retrieve.exists()) {
      console.log('still exists')
    } else {
      console.log('it worked!')
    }
  } catch (error) {
    console.error(error, 'nope')
  }
}
deleteOne()

Here is the error I get from the deleteDoc function I wrote:

index.js:1 TypeError: Cannot use 'in' operator to search for '_delegate' in undefined at Tc (index.esm2017.js:14691) at ph (index.esm2017.js:17522) at deleteOne (Firebase.jsx:101) 'nope'[enter image description here][1]

retrieve object that is console.logged [1]: https://i.stack.imgur.com/srxpq.png error in console [2]: https://i.stack.imgur.com/p2xQk.png

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

deleteDoc needs a DocumentReference. What you are passing is the DocumentSnapshot. If you use deleteDoc(docRef), you shouldn't get this 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