Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!