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

261
Views
Cómo obtener datos de una matriz multidimensional en firebase

Hola, mi base de datos se ve así:

Captura de pantalla de la base de datos

 "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" } ]

Provisto en la imagen y quiero obtener datos en los que he agregado código

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

donde pincode es "560074", por lo que el resultado es una matriz vacía. tambien he probado con codigo

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

que nuevamente está dando una matriz vacía. ¿alguna solución para obtener datos en función del código PIN de item_text?

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

0

Los operadores array-contains y array-contains-any verifican si el valor que pasó coincide con un elemento completo en la matriz; no se pueden usar para hacer coincidir un subconjunto de un elemento.

Entonces, con su estructura de datos actual, tendrá que usar esta consulta:

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

Si no conoce todas las propiedades del elemento, la solución común para permitir su caso de uso es agregar un campo de matriz adicional con solo los valores que conoce y luego consultarlo.

Así que para ti sería un campo delivery_pincode_item_texts :

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

A continuación, puede consultar eso con:

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

o

 .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!