1

I have a Firebase database that I'm trying to query, however I'm getting a error at run time saying

java.lang.IllegalArgumentException: Can't call equalTo() and startAt() combined

My database is as follows

DB

   //DB refrence
    myBikesDB = FirebaseDatabase.getInstance().getReference().child("Bikes  Registered By User").child(ronan);

    //query
    query = myBikesDB.orderByChild("beaconUUID").startAt("!").endAt("~").equalTo(true, "stolen");

So with the query im attempting to return all DB object where the value beaconUUID is not null, this bit works correctly.

However, once I add a second criteria .equalTo(true, "stolen"), I get the above stated error.

Is there any way I can return all items that have the value beaconUUID as not null AND have stolen set as true.

Thanks in advance.

AL.
  • 36,815
  • 10
  • 142
  • 281
RoRo88
  • 306
  • 1
  • 4
  • 14
  • I would recommend add one more value that combine `beaconUUID` and `stolen` as it is faster. But [here is the detailed post that might help you](http://stackoverflow.com/a/26701282/4112725) – koceeng Feb 23 '17 at 12:57
  • Firebase Database queries can only order/filter on a single property. Often you can combine the multiple values into a single property to allow your use-case. See http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Feb 23 '17 at 14:06
  • You'll need to remove `.startAt("!").endAt("~")` from the query. – doublejosh Jan 31 '22 at 06:57

1 Answers1

1

In my opinion you cannot make this query. The error message is pretty clear. But what you can do its to iterate throught all your response's items and filters thoses who have the attribute "stolen" to true.

Cedric Franck
  • 526
  • 4
  • 9