5

Consider following firebase structure :

{
  "users" : {
    "00:03:aa:dc:1c:2b" : {
      "firstName" : " Ofek",
      "groupName" : "thailand",
      "lastName" : "Ron",
      "registration" : {
        "type" : "regular",
        "time" : 1418288589636
      },
      "phoneNumber" : "345345345"
    },
    "04:46:65:8D:60:C6" : {
      "firstName" : " Ofek",
      "groupName" : "thailand",
      "lastName" : "Ron",
       "registration" : {
        "type" : "regular",
        "time" : 1418288589630
      },
      "phoneNumber" : "345345345"
    },
  }
}

how do you implement the following query :

SELECT * FROM USERS WHERE groupName="thailand" and registration.time>=1418288589631

I was trying to do it like this :

fireBase.orderByChild("groupName").startAt("thailand").endAt("thailand").orderByChild("time").startAt("1418288589631")

but that threw an exception since firebase doesnt allow multiple orderbys...

Any ideas?

Ofek Ron
  • 8,354
  • 13
  • 55
  • 103
  • 2
    Firebase currently only supports a single `orderBy` per query. So if you want to filter on more property, you'll either have to do the additional filter client-side in your JavaScript code or you'll have to come up with your own indexing scheme that combines the properties. – Frank van Puffelen Dec 11 '14 at 22:21
  • This should be an answer Frank! – Kato Dec 23 '14 at 18:06

1 Answers1

8

Firebase currently only supports a single orderBy per query.

So if you want to filter (or order) on more than one property, you'll either have to do the additional filtering (or ordering) client-side in your JavaScript code or you'll have to come up with your own indexing scheme that combines the properties.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807