KennyK
Convex Community5mo ago
11 replies
Kenny

Support for overlap date range queries (w/start + end fields)

Hi there,

To my understanding, there is no way to to query entities (e.g. a booking {start:isostring, end:isostring}) that have both
start
and
end
fields by a date range that isn't at risk of hitting the convex document limit, not by the documents within the date range, but by the nature of the amount of documents I have to scan so I can return a valid result due to how convex allows you to query the db.

- Where the risk is: writing a convex query to get all bookings that start before
start
AND end after
end
could likely exceed the 16k limit.

- For my usecase I want to surface all bookings between a range. I can get all that start between
start
and
end
and end between
start
and
end
without risk, but cannot get the bookings that start before
start
AND end after
end
before without risk of hitting doc limit.

- My understanding is you can't use an indexed query for
booking.start <= end && booking.end >= start
. Therefore I am forced to either collect all
booking.start < start
(which is a risk for doc limit) and from this result filter what also ends after
end
or the other way around (
booking.end > end
and then filter from this everything that also starts before
start
)

Am I incorrect or missing something? if not, are such range queries planned to be supported in the future?
Was this page helpful?