Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!