Multi-day events Firebase query

Viewed 74

I'm building this application that requires multi-day todo's. Not sure how to query those though in Firebase.

If I set an start and end time, then I can't query on those two fields due to firebase limitations.

now > start date & now < end date

I can use an array and check if a date is in there, but then I can't query more than 10 days at the time. Which would not be handy for month schedules.

What would be a smart way to store and query this data?

current query with single day events

$fire.firestore
      .collection('bonnen')
      .where('eventDateTime', '>=', rangeStart)
      .where('eventDateTime', '<', rangeEnd)
1 Answers

As you mentioned, these kind of queries are not supported in Firestore in order to meet performance guarantees.

What is recommended instead is that you make two separate queries and then filter the results according to your needs, so your queries would look like this:

$fire.firestore
      .collection('bonnen')
      .where('eventDateTime', '>=', rangeStart)

$fire.firestore
      .collection('bonnen')
      .where('eventDateTime', '<', rangeEnd)

After this filter the results in the code to get the necessary data, in your case you would have to get the common values in the results of each query.

Related