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

195
Visualizações
Bulk way to determine of all paths, which one exists (Possibly in one API Call)

I have an array of strings and want to check which of all those documents exist in my Firestore in two ways:

I am using Node Admin SDK:

import Server from '../../../../firebase/firebase_server_exports';

export const databaseEntryExists = async (paths: string[]): Promise<string> => {
  const promises = paths.map(
    (element) =>
      new Promise((resolve) => {
        Server.db
          .doc(element)
          .get()
          .then((doc) => resolve(doc.exists ? element : ''));
      })
  );
  const results = await Promise.all(promises);
  return results.includes(true) ? paths[results.indexOf(true)] : '';
};

Though this method works nicely, if I have 100 paths, I will be making 100 API calls which doesn't sound a good deal to me. Can someone suggest any Fierstore utility function or something like batch document fetching in order to reduce this to one API call?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In the Node.js SDK, you can create DocumentReference objects for all IDs and then use getAll() to get them all in one go. See the documentation for getAll() for an example.

This call does not exist in the client-side SDKs though, so the closest you can get there is to combine up to 10 IDs in a single call by querying on FieldPath.documentId() and using the in operator. There is nothing to request

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