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

136
Vistas
Is there some way where I could query this Map where I will only retrieve the data of those less than 5?

I have these documents inside the collection.

Document 1

enter image description here

Document 2

enter image description here

For every document in these collections, these items of the map would have different values. Is it possible to query those items that have a number below 5?

For example:

  • desctiption1
  • Item1 - 5
  • Item6 - 5

And then for the description 2:

  • description2
  • Item 2 - 5
  • Item3 - 4

So far, this is what I have done:

 const getData = async () => {
      const querySnapshot = await getDocs(collection(db, "collectionDesc"));
      const q = query(querySnapshot, where("map", "<=", 5));
      const arr = [];
      querySnapshot.forEach((doc) => {
        arr.push({
          ...doc.data(),
          id: doc.id,
        });
      });
      if (isMounted) {
        console.log(arr)
      }
    };
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As b2m9 commented, this is not possible as your query compares the map field to the primitive value 5 you pass, which will never be equal.

To implement this use-case, you'll have to add additional data to your document, like a field that tracks the lowest value in the map field. Say you call this lowestValueInMap and its value is 4 based on your sample document, you can then query it with:

query(querySnapshot, where("lowestValueInMap", "<=", 5));
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