I created an index on faunadb to sort by the time stamp in order to get the most recent items first, and I am trying to retrieve 100 items at a time. My problem is that when I enter the "after" parameter from the result, I receive the same results as the initial query.
This is the index I created:
CreateIndex({
name: "all_school_queries",
source: Collection('<school_queries_reversed>'),
values: values: [
{
field: ["ts", {reverse: true}]
},
{
field: ["ref"]
}
]
})
This is how I am querying the database:
Map(
Paginate(Match(Index("school_query_reverse")), {
after: [ Ref(Collection("collection_name") ,'collection ref from first query')],
}),
Lambda(
['ts',"ref"],
Get(Var("ref"))
)
)
and this is the first result:
{
before: [Ref(Collection("collection_name"), "275484304279077376")],
after: [
1598907150720000,
Ref(Collection("school_queries"), "12345"),
Ref(Collection("school_queries"), "12345")
],
}
I have used both the timestamp for the after, 1598907150720000 and the ref, 12345. I tried the console first to make sure I could get the right response, but upon entering the either result from the after, I get the same result.
I'll try to answer your question (I'm the dev adv at FaunaDB). I have to say that I'm quite confused by your question due to syntax that doesn't seem to make sense to me, so I apologize if it's not the answer you are looking for.
Things that I'm confused by.
Doesn't matter though, I tried to reproduce your issue, since I don't have an idea how the data looks I kept it simple.
The index I used looks as follows:
If I then query this index as follows:
I do get the last element I added first (reverse index)
and when I use the returned after cursor to get the next page (I have specified pages of only one element here):
I do get (as expected) the other element.
Is that not working for you?