Reputation: 1639
I've just upgraded my iOS application to use firebase 3 and a query which was working in firebase 2 no longer works in firebase 3.
The old query was written as follow.
fireBaseUser.queryOrderedByChild("displayName").queryEqualToValue(friendDisplayName)
.observeSingleEventOfType(.Value, withBlock: { snapshot in
}
where friendDisplayName could have been 'someguy1' and that would have returned the object that someguy1 was part of.
Now however, the same query returns nothing on firebase 3. I get the feeling that it is because firebase 3 isn't looking inside the child objects themselves, it's looking for displayName to be the actual child itself. If i update it to this query for example it returns as expected.
database.child("0hfTq3CTtFWNFvG0dmea1rAYpoW2").queryEqualToValue("someguy1", childKey: "displayName").observeSingleEventOfType(.Value, withBlock: { snapshot in
}
but obviously this won't work as a solution for me because I don't want to have to parse through the child nodes and then search through them etc.. the way i see it one solution would be if firebase had a 'catch all' where you could specify a child to be something like
database.child(*****).etc
where the **** can be any value, doesn't need to be specified in the actual query.
Does anyone know how to resolve this issue? I've attached the firebase JSON layout below.
Thanks!
{
"users" : {
"0hfTq3CTtFWNFvG0dmea1rAYpoW2" : {
"displayName" : "someguy1",
"pushOptions" : 1,
"pushToggle" : false
},
"9BATNLBnnoXMOvK4lHtQfmNGJJy1" : {
"displayName" : "someguy2",
"pushOptions" : 0,
"pushToggle" : true
}
}
}
Upvotes: 1
Views: 862
Reputation: 1639
I actually found out that despite there being no documentation on it, displayName acts as a keyword - the user object provided to you by firebase now offers a displayName property, but unlike most other databases, you can't use displayName in any other nodes or children - well you can, but it's not searchable. In the end changing the displayName property to be userName solved all my problems.
Hope this helps anyone else.
Upvotes: 2