Hello,
I am new to FaunaDB and struggling with one query.
I would like to get documents that are within a certain date range.
I have documents that have start and end fields, these are timestamps.
The query could work with max(user.start, document.start) <= min(user.end, document.end)
but I am struggling to create the right query.
For example:
Document has Start 10 Oct 2020 and End 11 Oct 2020
User selects a range to search for:
Start 10 Oct 2020 End 10 Oct 2020 - returns the document
Start 9 Oct to 2020 End 10 Oct 2020 - returns the document
Start 9 Oct to 2020 End 12 Oct 2020 - returns the document
Start 10 Oct 2020 End 12 Oct 2020 - returns the document
Start 12 Oct 2020 End 14 Oct 2020 - does not return the document
Document can look like this:
{
“id”: “5443aa42-b79a-4725-a972-37442894d4f1”,
“type”: “track”,
“start”: 1614730066522,
“end”: 1614730067577
}
Thanks a lot, I am open to any suggestions when it comes to structure, e.g. creating some helper tables if the above is not possible, etc.
FYI I have read similar discussion (Indexing on Dates, Conflict-Checking for Appointments - #3 by databrecht) but I am still lost.