Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
Firestore - Web version 9 - get all documents in collection whose id is in array of ids

I'm new to Firestore and trying to form a query to return all documents whose doc.id is in an array of ids.

So something like this:

const getAlbumSongs = async (songUids) => {
    let albumSongs = [];
    const q = query(collection(db, 'songs'), where('id', 'in', songUids));
    const snap = await getDocs(q);
    if (snap) {
      for (const doc of snap) {
        albumSongs.push({
          songId: doc.id,
          albumId: doc.data().album_id,
          authorId: doc.data().author_id,
          songTitle: doc.data().song_title,
          filePath: doc.data().file_path,
        });
      }
    }
    return albumSongs;
  };

I should note I'm calling the getAlbumSongs() function from within a getAlbums() function, like this:

  async function getAlbums() {
    setIsLoadingAlbums(true);
    const snap = await getDocs(collection(db, 'albums'));
    setIsLoadingAlbums(false);
    let albumsData = [];
    if (snap) {
      snap.forEach(async (doc) => {
        albumsData.push({
          ablumId: doc.id,
          albumTitle: doc.data().album_title,
          albumCoverUrl: doc.data().cover_url || 'https://picsum.photos/300',
          albumSongs: await getAlbumSongs(doc.data().song_uids), // this might be problematic?
        });
      });
      console.log('albumsData', albumsData);
      return albumsData;
    }
  }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your current code queries on a field called id in each document. If you want the document ID itself, that is part of the metadata of the document and you'll want to query on documentId() for that:

const q = query(collection(db, 'songs'), where(documentId(), 'in', songUids));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda