I am creating a pagination on scroll using faunadb and vuejs. To achieve the pagination, I am passing the ref of the last entry from the original response, and doing a query using after, For some reason I am still getting the same response as the origin array. It is important to mention that my initial query is a reverse query based on the time stamp property, as to get the latest items first. I do not think this should cause an issue, Any advise is welcomed. My initial query, does not have an after field.
await client.query(
q.Map(
q.Paginate(
q.Match(q.Index("school_query_reverse")),
{
after: [q.Ref(q.Collection("school_queries"), params.params.id)],
size: 100
}
),
q.Lambda([
'ts',
'ref'
],
q.Get(q.Var("ref"))
)
)
)
This is a duplicate question which I already answered here. Would you consider editing that one instead of opening a new one with extra information to keep Stack Overflow organized?
Given that your index contains two values (ts and ref) which I can derive from your lambda and from your previous question, this after syntax will not work. You will have to specify at least three values. Such a cursor will look like this:
You might wonder why there are three values in there. That's because the index contains your reference and the reference is always added to the cursor. Using it again in the index results in it being added twice. Why and/or whether we can't optimise I can't tell but that's just how it works currently :).
If I adapt the after in your query, that'll become something like: