0

I'm trying to retrieve all car data where name is golf but i get no results:

This is my query:

ref.child("auto").queryOrdered(byChild: "name").queryEqual(toValue: "golf").observeSingleEvent(of: .value, with: { (snapshot) in 

my Firebase structure is:

-auto --luhrvuuigvuilthuv ---tgrebytfbyuhbyujvyjb ----name:golf ----age: 2 ----color: blue ---funjityvniyyuhntyity ----name:golf ----age: 2 ----color: blue 

Where is the problem? Thnx in advance

5
  • The Firebase Database queries child nodes of the location. The property you filter on must be at a fixed location under that child. And luhrvuuigvuilthuv doesn't have a property name, so the query doesn't match anything. It looks like you're trying to implement categories, for which I described a good data model here: stackoverflow.com/questions/40656589/… Commented Feb 18, 2017 at 14:34
  • Thnx man, luhrvuuigvuilthuv is the userid and tgrebytfbyuhbyujvyjb and funjityvniyyuhntyity are childbyautoid. name property is under childbyautoid, how can i do? Commented Feb 18, 2017 at 14:40
  • You'll need to pull up the name into a list of names. See my answer to the question I linked in the first comment. Commented Feb 18, 2017 at 14:53
  • so i have to create in firebase another list when a new car is entered? sorry but i'm new to firebase... thnx anyway Commented Feb 18, 2017 at 15:09
  • now i modified my node in this way: -auto --sfghsedhsrtr (autoID of the car) ---addedbyuser: sdgergergh ---namecar: golf ---age:2 ---color:blue Now i can make my query i added indexOn namecar the new problem is that when i want to see all the car from a specific user it shows me but in the output i see that it's better that i indexed addedbyuser and this is impossible... should i wrote another node like the foldaway and keep both? Commented Feb 20, 2017 at 12:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.