I have 2 spinners ,for services and employees.
in my app i want to let user choose list of services then i fill the employee spinner only for employee who available for that service
i have employee class and structure similar like this :
"Employees" : {
"eid1" : {
"name" : "john",
"services" : {
//john has 3
"sid1" : "true",
"sid2" : "true",
"sid3" : "true"
},
"eid2" : {
"name" : "david",
"services" : {
//david only has 1
"sid2" : "true"
}
}
my service structure is :
"Services" : {
"sid1" : {
"name" : "read"
},
"sid2" : {
"name" : "write"
},
"sid2" : {
"name" : "erase"
}
}
example: if i choose service2, the query will find john and david. if i choose service1 then only john will be fetched and added to my spinner.
i confuse what the query i should use, i tested some, including this, but always skipped when i run it in debug mode:
mDatabase.child("Employees").orderByChild("services").equalTo(serviceList.get(position).getName()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot dsp : dataSnapshot.getChildren()) {
//System.out.println(dsp.getKey());
}
}