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

244
Vistas
UnhandledPromiseRejectionWarning: TypeError: firestore.collection(...).doc is not a function (Firebase, Firestore)

I am trying to set the verified field to true in my firestore database after authenticating the user. `I am able to get the query working but once i try and update it, i get this TypeError

UnhandledPromiseRejectionWarning: TypeError: firestore.collection(...).doc is not a function

Here is my full code.

app.post("/signIn", async (req, res) => {
  var email = req.body.email
  var password = req.body.password

  var response = {}
  response["errors"] = []
  response["feedback"] = []

  // Authenticate User

  await firebaseAuth.signInWithEmailAndPassword(firebaseAuth.getAuth(), email, password) .then(async (userCredential) => {
    const user = userCredential.user
    if (user.emailVerified) {
      // Get Doc
      const q = firestore.query(firestore.collection(db, "users"), where("user_email", "==", email));
      const querySnapshot = await firestore.getDocs(q)
      
      querySnapshot.forEach(async(doc) => {
        console.log(doc.id)

      // Update Field

        const res = await firestore.collection(db, "users").doc(doc.id).update({verified: true})
      })
      
      response["feedback"].push("Authenticated")  
    } else {
      response["errors"].push("Not Verified Email")
    }
  })
  .catch((error) => { 
    console.log(error.code)
    console.log(error.message)
    response["errors"].push(error.code) 
  })

  console.log(response)
  res.send(JSON.stringify(response))
})

I've been stuck at this for hours now. Also tried updating it through

const userRef = await firestore.doc(firestore.collection(db, "users"), doc.id)
const res = await userRef.update({verified: true})
about 4 years ago · Juan Pablo Isaza
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