1

I have a database that looks like this:

enter image description here

I want to order "points" and "size" so that, for example, guilds with most points using the following code:

rootRef.child("displayGuilds")
    .orderByChild("points")

and guilds with size greater or equal to "3" with the following code:

rootRef.child("displayGuilds")
    .orderByChild("size")
    .startAt(3.toDouble())

But I can't figure out how to achieve both of these requirements in a single query. I realize that there's another solution by combining and add another key like "size_points: 3_1562" but is there better way to do this in Firebase Realtime database?

Jay N
  • 348
  • 3
  • 11
  • 1
    The way you've found is the idiomatic way to do an AND on multiple conditions server-side. See my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Apr 04 '19 at 19:12
  • Hi, @FrankvanPuffelen. I've seen that post and thanks for confirming that it's the way to do it. Can I ask if there are any plans that Firebase will implement something similar to do it on the client side instead? – Jay N Apr 04 '19 at 20:40
  • You can already do additional filtering on the client-side. But if you mean adding the ability to filter on multiple values on the server, then there's currently no work to plan that on RTDB. You might want to look into using Cloud Firestore, Firebase's new flagship database, which does allow filtering on multiple fields in its API. – Frank van Puffelen Apr 05 '19 at 00:11

0 Answers0