How to execute the following query in Firebase? (more than one where condition)

Consider the following base 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 to implement the following query:

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

I tried to do it like this:

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

but this threw an exception because firebase does not allow multiple orderbys ...

Any ideas?

+4
source share
1 answer

Firebase currently only supports one orderBy per request.

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

+6
source

Source: https://habr.com/ru/post/983458/


All Articles