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

243
Visualizações
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 à 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