I have firebase like this (I Can't change the table design)
{
"Visits" : {
"-LOyE4h8k218xg-SI2Hy" : {
"Enabled" : false,
"visitorLocation" : "01",
"visitorId" : "22"
},
"-LOyG4__aiiJ3FBVnWbU" : {
"Enabled" : false,
"visitorLocation" : "02",
"visitorId" : "22"
},
"-LOyG5Wyu3cZmZFaCBxY" : {
"Enabled" : false,
"visitorLocation" : "03",
"visitorId" : "22"
},
"-LOyG7gkUj8OFdEsyBGS" : {
"Enabled" : false,
"visitorLocation" : "04",
"visitorId" : "22"
}
}
}
Stored in the firebase,
I would search using visitorLocation and visitorId, and then change the Enabled value.
what i have right now:
DatabaseReference ref =
FirebaseDatabase.getInstance().getReference("visitores");
//This is good, Returns the 4 nodes.
Query q = ref.orderByChild("visitorId").equalTo("22");
q.orderByChild("visitorLocation").equalTo("01").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
dataSnapshot.getChildren().iterator().next().getKey();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
but later i get error: You can't combine multiple orderBy calls! can anyone help ? how can i search by multiple key values ?
Thank you !!!