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

349
Visualizações
Is there some way to get a specific field from one get request with Firestore(Firebase)?

So here is the request to get some data from Firestore with vanilla JS.

const q = query(collection(db, "tasks"), where("userId", "==", "Milos"), where("archive", "==", "false"));
const querySnapshot = await getDocs(q);
querySnapshot.forEach((doc) => {
  // doc.data() is never undefined for query doc snapshots
  console.log(doc.id, " => ", doc.data());
});```
With this request, I get a from collection tasks where userId equals "specificname", and where the archive field is equal to false. So with this request, I will get full tasks, is there some way with Firestore to get only a specific field or fields, not a full task with all fields? Is something even possible with Firestore or do I need to parse this object on the front side?  
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

No, you cannot retrieve partial responses from Firestore on the client. Every request will always return all documents to the client. This also means you cannot protect certain fields in a document.

Server-side you could try using Query.select.

let collectionRef = firestore.collection('col');
let documentRef = collectionRef.doc('doc');

return documentRef.set({x:10, y:5}).then(() => {
  return collectionRef.where('x', '>', 5).select('y').get();
}).then((res) => {
  console.log(`y is ${res.docs[0].get('y')}.`);
});
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