Skip to content

Last and Before includes cursor from previous page #499

Answered by woylie
Niedman asked this question in Q&A
Discussion options

You must be logged in to vote

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 same created_at value.

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
12 replies
@Niedman
Comment options

@woylie
Comment options

@Niedman
Comment options

@woylie
Comment options

Answer selected by Niedman
@woylie
Comment options

@Niedman
Comment options

@woylie
Comment options

@Niedman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants