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

153
Views
Firebase update spesific collection

I want to update a score value within a specific collection that is within a document called competitions.

I would like to update a specific collections data values, but it gives me this error:

FirebaseError: Expected type 'gc', but it was: a custom yc object

My query is probably wrong, but how can I update a specific value within a collection?

const colRef= query(collection(db, 'competitions/'+id+'/scorecard'), where("id", "==", scorecardid));
return updateDoc(colRef, {finalscore:300}, { merge: true });

Underneath you can see the db struncture from competitions to scorecards the get a scorecard spesific id and the you want to update that scorecard finalscore.DB structure

DB structur 2

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

0

The updateDoc() takes a DocumentReference as first parameter but you are passing a Query. There isn't any updateDocsWhere functionality in Firestore at the moment. You'll first have to run that query and then iterate over all documents and delete them using their reference. Try refactoring the code as shown below:

const colRef= query(collection(db, 'competitions/'+id+'/scorecard'), where("id", "==", scorecardid));

const snapshot = await getDocs(colRef);

const promises = snapshot.docs.map((doc) => updateDoc(doc.ref, { finalscore:300 }));

await Promise.all(promises);

Alternatively, you can also use Batched Writes to update up to 500 documents at once.

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!