I have a table of events
in Firestore. These events a part of multiple fields, it have startDate
and endDate
fields that are Timestamps
I have to 3 types of queries to do related to this fields.
- Events that start after/equals at specific time [X]
- Events that ends before/equals at specific time [X]
- Events that in a range of time. [-]
For the last query, I tried something like:
Firebase.firestore.collection("events")
.whereGreaterThanOrEqualTo("dateStart", dateStart)
.whereLessThanOrEqualTo("dateEnd", dateEnd)
.get()
.addOnSuccessListener {
if (it.isEmpty) {
Logger.d("Empty")
} else {
Logger.d(it.documents)
}
}
(Where dateStart/dateEnd are Date()
)
The problem is that firestore is launching an error:
All where filters other than whereEqualTo() must be on the same field. But you have filters on 'dateStart' and 'dateEnd'
And I'm stucked at this point. Is there a way to achieve this doing the queries?
Or I will have to query just for greater
or less
and then when I got the results filter in the app?