filtering pagination
When using
getPages
(from convex-helpers/server/pagination
), how can I apply a filter (or search)
? I would to pagination through the table payments
but only on a subset of this table. But I can't see a way to apply a filter. It looks like the pagination applies to the whole table by default7 Replies
you can get a page with
getPage
and then filter it with TypeScript's Array.filter
methodThanks @lee . So that basically means I should first query the "whole" table and then apply Array.filter? I'm expecting this table to have hundreds of thousands of records.
can you define an index and bound the query with an index range?
out of curiosity, why are you using
getPage
as opposed to .paginate
?This is my use case: I'm building a page with a table where the user should be able to "jump" to an arbitrary page number, and not only sequentially walk through the data, page after page. I'm not sure how I can implement this with
convex
. In other words: how can I implement a take n, skip k
type of query.
So I'm going through the documentation and I'm not sure how getPage
or .paginate
can help me to achieve that.
I see there is a discussion here of the type of pagination I would like to accomplish
https://discord.com/channels/1019350475847499849/1096524377891295353neither
getPage
nor .paginate
can do that very well. there's no concept of "skip"
if you imagine all of your documents in an array sorted by some field, can you come up with an algorithm that has sublinear runtime?I was thinking of maintaining some sorte of "order_index" column on the table I can use to "skip". Where I'm stuck is what to do if a record is deleted. (I can run an algorithm to recalculate the new "order_index" values. But I'm afraid the algorithm will get slower as the table is growing...)
that works but you're right that deletes are a problem. there's a component that solves this case if you're interested in requesting early access https://form.typeform.com/to/khLQQ6N8
Convex Product Feedback Form
Convex Product Feedback Form