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

134
Views
How to query and update in firestore v9
async booleanFunction(email: string, bool: boolean){
    console.log('here')
    const db = getFirestore();
    const q = query(collection(db, "users"), where("email", "==", email), limit(1));
    const querySnapshot = await getDocs(q);
    await updateDoc(querySnapshot, {
      disabled: !bool
    });
}

Here is my function which takes in email and a bool value(this needs to be updated), I don't have the _id that firestore provides so I need some alternate to query data and update it

This the the error that shows up

Argument of type 'QuerySnapshot<DocumentData>' is not assignable to parameter of type 'DocumentReference<{ disabled: boolean; }>'.

Type 'QuerySnapshot' is missing the following properties from type 'DocumentReference<{ disabled: boolean; }>': converter, type, firestore, id, and 3 more.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is here:

await updateDoc(querySnapshot, {
  disabled: !bool
});

You're trying to call updateDoc on a QuerySnapshot, which isn't possible and never has been possible on v8 either.

You can only call updateDoc on a DocumentReference. So you will have to loop over the documents in the QuerySnapshot and call updateDoc on each of them:

await Promise.all(() => 
  querySnapshot.docs.map((doc) => 
    updateDoc(doc.ref, { disabled: !bool })
  )
)
about 4 years ago · Juan Pablo Isaza Report
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!