I am building a calendar on IOS using Swift, with a Firestore back-end.
I am retrieving all the events for each day in a month at one time.
Currently I can only display events that start on a particular day.
This is no good if an event starts on a Friday night and ends on a Monday morning (think, weekend on holiday).
so...
I need to get all the Event documents from Firestore where the day currently being populated with events sits between the timestamps of the start and end fields on the Firestore document.
The obvious first choice is something like this:
db.collection("Event")
.whereField("user", isEqualTo: userID)
.whereField("start", isLessThanOrEqualTo: thisDate)
.whereField("end", isGreaterThanOrEqualTo: thisDate)
.getDocuments()
but it turns out Firebase won't let me run 2 inequality filters on different fields [:(
The only other option I can think of is to get all the events that started before today, scan through each one and check if it ended before today, then display the rest.
But this doesn't seem very efficient, especially if you think about 5 years down the line when a user might have an event for every day of the year (that's A LOT of documents to check through in a short space of time).
Does anybody have any suggestions as to how I might do this?
Thanks :)
UPDATE
I forgot to add this in, It's a screenshot of how the database is structured :)
(note that day, month, and year are obsolete fields now that I have started using timestamps)
