I want to Query Objects from a Collection where "equipmentOption" == equipmentOption || "equipmentOption" == -1.
After researching this problem I came to the conclusion that this is not possible with Firestore Querys. Is that correct or is there a way to query like this?
So my Solution was to have two separate Queries like this:
Task<QuerySnapshot> routinesWithEquipmentOption = doc.getReference().collection("Routines").whereEqualTo("equipmentOption", programm.getEquipmentOption()).get();
Task<QuerySnapshot> routinesWithoutEquipmentOption = doc.getReference().collection("Routines").whereEqualTo("equipmentOption", -1).get();
and the somehow merge this query. Thats what I accomplished:
Tasks.whenAllSuccess(routinesWithEquipmentOption, routinesWithoutEquipmentOption).addOnSuccessListener(new OnSuccessListener<List<Object>>() {
@Override
public void onSuccess(List<Object> objects) {
}
});
In this OnSuccessListner I get a List of Objects. This confuses me, what information do these Objects contain. Is there a way to convert them to a DocumentSnapshot so I can call .toObject()
? Also it seems like I don't get anything back because onSuccess is never called.