David TejadaD
Convex Community3mo ago
12 replies
David Tejada

Keep paginated query from growing with new items

I have a paginated query that in the client I retrieve with usePaginatedQuery. The problem is whenever there's new items the results array grows with items I don't want to show at that point. Right now I am filtering out those new items in the client using the _creationTime of the first item that I have kept. This works but the results in the paginated query hook state keep growing unnecessarily.

What is the recommended way of solving this? I have asked the docs AI and it has recommended using a timestamp and retrieving only items older than that. I can run another query for items newer than the timestamp to know if there are new items too. If I want to do that I need to generate the timestamp in the backend with another query because doing it in the frontend could be problematic, right? Is there a better way to solve all this that I'm missing?
Was this page helpful?