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

160
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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