-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to read previous and next row based on column id #1165
Comments
Hey! We already have support for cursor based pagination, you can find more information and examples on https://xata.io/docs/sdk/get#the-typescript-sdk-functions-for-querying. The |
You might be misunderstanding me. There are many cases where pagination is far too bloated, and unusable, for the kinds of requests needed. For example, if you are building a gallery application where you want a previous and next button for the photos. What you are saying to me is the way to move back and forward over each photo is to request ALL the photos and then find the photo that the user has landed on in the list, compute where in the order it is in, to then have the information to render the page properly? If the gallery app has direct individual pages for each photo. At like /image/[imageid] for example. All the information the developer has is the [imageid] (which isn't just a incrementing number). How would any developer scale that properly? They wouldn't use pagination. They would make a simple sql request which is like |
In those scenarios you can use the new SQL endpoint, for other feature requests please send them over to https://feedback.xata.io/feature-requests |
hey @Mrawesomes thanks for the feedback on this! To make sure, you can do the equivalent of const users = await xata.db.Users
.select(["id"])
.filter({ id: { $gt: "effie" } })
.getFirst(); Would that help? Just making sure you know you can use the I did open a feature request for |
The ability to be able to easily pull the previous or next row based on the column id allows for simple per row pagination.
For example if someone is creating a blog and they want to show the previous and next blog post as links there is currently no easy way to do that.
I propose that in addition to the getFirst() there is a getPrevious() and getAfter() method. Each method would take at most three parameters (one requires, two optional).
While you could potentially do this with pagination while keeping a state of all ids and offsets or raw sql it's not intuitive.
The text was updated successfully, but these errors were encountered: