Repository navigation
Use built-in pagination instead of paginator - #88
ianmacartney wants to merge 2 commits into
Conversation
Switch listMetadata to ctx.db.query(...).paginate(). Temporarily install convex-test from pkg.pr.new (convex-test#163).
commit: |
listMetadata previously dropped paginationOpts.endCursor, so pages from usePaginatedQuery could shift. Add optional endCursor, maximumRowsRead and maximumBytesRead args to the component's listMetadata and forward them from the client.
|
Hold until 10/22. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Change: Refactor Merge Risk: ⚪ Minimal · up to
|
src/component/lib.ts:listMetadatanow uses built-inctx.db.query("metadata").withIndex("bucket", ...).paginate(...)instead ofpaginatorfromconvex-helpers/server/pagination. Return shape is unchanged (paginationReturnValidatoralready allowssplitCursor/pageStatus).convex-helpersstays in package.json becauseasyncMapis still imported.convex-testtemporarily points at https://pkg.pr.new/convex-test@163, which enforces the one-.paginate()-per-transaction rule, until a real release.Notes:
.paginate()once per transaction (shared across the app function and nested component calls). An app callinglistMetadata(viaR2.listMetadataor the generatedclientApi().listMetadata) in a transaction that already paginated, or calling it twice in one transaction, will get an error.Separate fix:
listMetadatadroppedendCursor(existed before this PR)clientApi().listMetadataacceptedpaginationOptsbut forwarded onlynumItemsandcursorto the component.endCursorwas dropped, so pages fromusePaginatedQuerycould shift, leaving gaps or overlaps between pages. This bug existed before this PR; the paginator version had it too.lib.listMetadatatakes new optional argsendCursor(string | null),maximumRowsReadandmaximumBytesRead, and passes them to.paginate().src/component/_generated/component.tswas regenerated withnpm run build:codegen.R2.listMetadata(ctx, limit?, cursor?, opts?)takes a new optional fourth argument{ endCursor?, maximumRowsRead?, maximumBytesRead? }.clientApi().listMetadataforwards those fields frompaginationOpts.src/component/lib.test.ts, which checks thatendCursorends the page at that cursor whateverlimitis.