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

264
Views
How to fetch data from multidimensional array in firebase

Hello my Database looks like this:

Database screenshot

"delivery_pincode": [
      {
        "item_id": "106380730",
        "item_text": "560074"
      },
      {
        "item_id": "119323097",
        "item_text": "562164"
      },
      {
        "item_id": "126726811",
        "item_text": "560050"
      },
      {
        "item_id": "129564907",
        "item_text": "560115"
      }
]

Provided in the image and I want to fetch data in which I have added code

.where("delivery_pincode","array-contains-any" , pincode)

where pincode is "560074" so the result is giving empty array . I have also tried with code

.where("delivery_pincode","array-contains-any" , [item_text: "560074"])

which is again giving empty array . any solution to fetch data based on item_text's pincode ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The array-contains and array-contains-any operators check whether the value you passed matches a complete item in the array; they can't be used to match a subset of an item.

So with your current data structure, you will have to use this query:

.where("delivery_pincode","array-contains", {"item_id": "106380730",item_text: "560074"})

If you don't know all properties of the item, the common workaround to allow your use-case is to add an additional array field with just the values you do know, and then query on that.

So for you that would be a field delivery_pincode_item_texts:

delivery_pincode_item_texts: [
  "560074",
  "562164",
  "560050",
  "560115"
]

You can then query that with:

.where("delivery_pincode_item_texts","array-contains-any", ["560074"])

or

.where("delivery_pincode_item_texts","array-contains", "560074")
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!