Range query with dates

Hello! I seem to have hit a wall. I am trying to do a simple query to get a list of documents between two dates. Right now my plan is to just pass a single date in the query and calculate “last 7 days”, “last month” etc.

The document model:
type Report @collection(name: "reports"){ user: User! date: Date! }

I have an index: reports_by_date

I know that the index works:

I am trying to make it work through a graphql query. Currently the resolver function looks like this and it returns empty:
Query( Lambda( ["date"], Select( ["data"], Map( Paginate( Range( Match(Index("reports_by_date")), TimeSubtract(Var("date"), 22, "days"), Var("date") ) ), Lambda("x", Get(Var("x"))) ) ) ) )

I have tried some FQL tests with no luck:

Range works on the values returned by the index, not the terms of the index.

Your Match will return an empty Set because you’ve not provided any terms.

Can you try with a different index, one with no terms and the date and the Ref as values? then you should be able to use Range over that index.

1 Like

That was the solution! Much appreciated.

For anyone wondering, this is the resolver function for people in a similar situation:

TimeSubtract(Var(“date”), 22, “days”),
Lambda([“date”, “ref”], Get(Var(“ref”)))