0

I have following structure, cities is an array.

-NodeX 
 -KtI6rv4Wf5eEZLLXqRp 
   name: MyName1  
   Description: My Desc1 
   Cities  
     0
      name:My City
      isBig: False 
    1    
      name:Your City
      isBig: True  
    2   
      name:His City   
      isBig: False 
-KtKHcUjNlBuZSY7_5kv  
  name: MyName  
  Description: My Desc  
  Cities  
    0
      name:My City   
      isBig: False   
    1
      name:Your City  
      isBig: False  
    2 
      name:His City 
      isBig: False
-Kuc1bpEcW2yJEq6OK72  
  name: MyName 
  Description: My Desc  
  Cities   
   0    
     name:My City 
     isBig: True  
   1    
     name:Your City
     isBig: True      
  2   
     name:His City 
     isBig: False

I want to get top level nodes having ANY city which is Big (isBig=True) i.e. I want to get following two nodes.

KtI6rv4Wf5eEZLLXqRp

Kuc1bpEcW2yJEq6OK72

Ideally, I want to use Polymerfire query element, but even if there is another solution, I would go with that.

Community
  • 1
  • 1
Naqash
  • 61
  • 4
  • 1
    There's no way in the Firebase Realtime Database to query such nested properties. You'll need to change your data structure to allow the query you want. See [my answer here for more](https://stackoverflow.com/questions/46801852/google-firestore-structuring-deeply-nested-ordered-data). – Frank van Puffelen Oct 18 '17 at 14:21

1 Answers1

0

That's not possible you have to change your data structure.

Something like this would be the way to go:

-cities 
  -KtI6rv4Wf5eEZLLXqRp 
    0
      name:My City
      isBig: False 
    1    
      name:Your City
      isBig: True  
    2   
      name:His City   
      isBig: False 
-info
  -KtI6rv4Wf5eEZLLXqRp 
    name: MyName1  
    Description: My Desc1 

Then you need to fetch your data.

Orlandster
  • 4,706
  • 2
  • 30
  • 45