Mark L
Mark L2w ago

Filters | Convex Developer Hub

How do you do both pagination and filtering on an array in convex? The docs example say to just filter them after the ctx.db.query, but I don't see how this could work with paginated queries. https://docs.convex.dev/database/reading-data/filters#advanced-filtering-techniques I think this is a pretty common useCase I have a table with tagIds and I want to find all results that has a specific tagId paginated, so I get e.g. 50 at a time. Does anyone know how to filter arrays in paginated queries? There will be >10k results and this will be the #1 called query in my app, so I do want to make it more efficient. The docs in several places suggest sorting in JS is not efficient when there's 1,000's of rows.
Filters | Convex Developer Hub
Filter documents in Convex queries
1 Reply
Barrel Of Lube
i recommend 1. create a ref table like https://github.com/0bs-chat/zerobs/blob/main/convex/schema.ts#L86 2. you can add an updatedAt (and create an index for this) column or use the _created(ion)Time field to filter by timestamps of the last query

Did you find this page helpful?