-
I'm using Cursor Based pagination and when i'm using first and after, the last element from the previous page is skipped as expected, however when i perform the last before operation the first element from the next page is actually moved to the last element of the current page. Is there a easy way of fixing this in Flop or we need to decode cursor and try to build a filter out of it? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Hi @Niedman, could you post the code I need to reproduce this? |
Beta Was this translation helpful? Give feedback.
-
Hi @woylie Sure :) Query:
Decoded cursor from before: Params
Fetch Data
do you want me to post the iterations that i do? I believe that behind the scenes Flop does a <= before and i guess what i´m looking for is to < before. that will exclude the repeated element. |
Beta Was this translation helpful? Give feedback.
Hey @Niedman, the answer is in the linked documentation: You can sort by any number of non-unique columns, but to ensure that the cursor indeed is unique across the dataset, you should include the primary key or another unique column in the order-by columns. So instead of sorting by
:created_at
only, you'd need to sort by[:created_at, :id]
. That would still give your users what they want, but ensure that cursor pagination works even if multiple rows share the samecreated_at
value.