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

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

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 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