Trying to query a firestore collection as below. Data returned is inaccurate.
db.collection("myCollection")
.whereField("date", isGreaterThanOrEqualTo: Timestamp(date: startOfMonth))
.whereField("date", isLessThanOrEqualTo: Timestamp(date: endOfMonth))
.whereField("createdBy", isEqualTo: String(Auth.auth().currentUser?.uid ?? "No user"))
If I provide only the first two whereField clauses (the dates), the data returned is accurate. If I provide only the third whereField clause (createdBy), the data returned is accurate
When I combine the two, no data is returned. Have checked the database, there should definitely be data returned. No error is thrown.
I also manually created a composite index on the fields “date” and “createdBy” but this made no difference. I’ve looked thoroughly and I believe I don’t violate any firestore limits for filters for equality and inequality filters.
Nikki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5