Reputation: 117
How can I implement a ranking where the user can see the top ten for girls or for boys? I know how to create a ranking where you can see the top ten of all users but I have no idea how to create a ranking where only girls or boys are shown. (I know that I could change the users node, but that is not a possibility because then I could not make a ranking of all users)
My users node looks as follows:
users
/$userId
/points
/sex
Upvotes: 0
Views: 39
Reputation: 83048
As explained in the documentation "you can only use one order-by method at a time. Calling an order-by method multiple times in the same query throws an error".
The most common approach to solve this "limitation" is to duplicate your data, which is quite common in NoSQL world.
You would then have a data model as follows:
users
/$userId
/points
/sex
femaleUsers
/$userId
/points
maleUsers
/$userId
/points
You would use the update()
method to keep the different nodes in synch.
Upvotes: 2