I am trying to find a session with a specific id (not key) without knowing the user id.
Database Structure
I had an initial attempt by looping through all the children of users and creating a new reference every time but it is not working and I can't figure out why nor I know if it should work in the first place.
database.child("users").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot snap : dataSnapshot.getChildren()){
database.child("users").child(snap.getKey()).child("sessions")
.orderByChild("id").equalTo(id)
.limitToFirst(1)
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot data) {
if (data.exists()) {
Session session = data.getValue(Session.class);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});

logto be more specific where your issue is