long story short, I am making an application for train timestamps, and so I have a cloud firestore database as my DB. The point of issue is that when users find specific times for departure I am using whereGreaterThanOrEqualTo for searching time, to be specific minutes and hours. If a user tries to find a route for 8:30, the application should return to the next route which is around that time. But when the user click finds a route, the app crashes... Here is the error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.projekatidemovozom/com.example.projekatidemovozom.SecondActivity}: java.lang.IllegalArgumentException: All where filters with an inequality (notEqualTo, notIn, lessThan, lessThanOrEqualTo, greaterThan, or greaterThanOrEqualTo) must be on the same field. But you have filters on 'departure.hours' and 'departure.minutes'
This is my code for fetching data from the database:
public void initDatabaseConnection() {
FirebaseFirestore db = FirebaseFirestore.getInstance();
CollectionReference timestampsRef = db.collection("timestamps");
timestampsRef.whereEqualTo("route.cityFrom", cityOd)
.whereEqualTo("route.cityTo", cityDo)
.whereGreaterThanOrEqualTo("departure.hours", hours) //ISSUE LINE
.whereGreaterThanOrEqualTo("departure.minutes", minutes) //ISSUE LINE
.get()
.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
TimestampModel tm = document.toObject(TimestampModel.class);
timestampModelList.add(tm);
Log.d(TAG, tm.toString());
}
} else {
Log.w(TAG, "Error getting documents.", task.getException());
}
});
}
This is my database structure:
So do you know what is the problem?