1

Let say I have this firebase database called "myBase":

{  
   "users":{  
      "0":{  
         "111":{  
            "id":"d3QwkugFZ7U",
            "message":"hello",
            "receiver":0,
            "responseType":0,
            "sender":111,
            "time":1505850305696,
            "type":"ANSWER"
         }
      },
      "11":{  
         "11":{  
            "id":"fT7S5OAh670",
            "message":"you",
            "receiver":11,
            "sender":11,
            "time":1505850305697,
            "type":0
         },
         "81":{  
            "id":"eubUPTN4IeQ",
            "message":"geeks",
            "receiver":11,
            "sender":81,
            "time":1505850305698,
            "type":0
         }
      }
   }
}

I want to retrieve the user with "time":1505850305697

My rest command is:

curl 'https://myBase.firebaseio.com/users.json?orderBy="time"&equalTo=1505850305697&print=pretty'

Following the documentation my rules are:

{  
   "rules":{  
      ".read":"auth == null",
      ".write":"auth == null",
      "users":{  
         ".indexOn": "time"
      }
   }
}

And I got nothing! :*(

1 Answers1

0

Firebase Database queries filter properties for each child of the location you execute the query on. So in your case, you're filtering /users/*/time. In your data model, the value you're trying to filter is /users/*/*/time. That sort of filtering on descendent properties is not possible in Firebase.

Also see: Firebase Query Double Nested

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807