0

I need to query something like this:

Select 20 users where (age is from 20 to 30) and (weight is from 50 to 80)

What is the most efficient way to achieve this in Firebase Realtime Database (for Unity)? Assuming "users" table has millions of records.

Any help is much appreciated!

mG.
  • 45
  • 1
  • 11

1 Answers1

0

I'm not sure there is a way to achieve this goal without rethinking the data structure.

What I would do if I were in design phase and I needed to query by tens of age is to put inside the user node a structure like this:

"userId": {
    ...
    "ageAndWeightFilter": {
        "20s": <weight>
    }
}

In this way you can query by range of weight and specifically a specific range of 10 years.

balsick
  • 1,099
  • 1
  • 10
  • 23