Skip to content

Support findMany offset via cursor pagination - #406

Draft
moritz-mode wants to merge 1 commit into
convex:mainfrom
neunzig-zehn:feat/findmany-offset
Draft

moritz-mode wants to merge 1 commit into
convex:mainfrom
neunzig-zehn:feat/findmany-offset

Conversation

@moritz-mode

Copy link
Copy Markdown

Motivation

findMany throws offset not supported, but some Better Auth surfaces pass offset — e.g. the dashboard's table paging. This PR supports it and re-enables the five upstream offset tests in @better-auth/test-utils.

Changes

The component paginates by cursor and stays cursor-only. The client fetches offset + limit rows through the existing cursor pagination and drops the first offset rows; offset is stripped from the component query args.

Cost

  • offset + limit reads exactly offset + limit rows — deep offsets cost proportionally, the same as any cursor-based store emulating offset. This is aimed at admin-style paging.
  • offset without limit can't be rejected (three of the four upstream offset tests pass offset with no limit), but it's cost-equivalent to the already-supported no-limit findMany, which pages 200 rows at a time to the end — no new unboundedness is introduced.

Tests

  • Re-enabled the upstream offset tests. The three sortBy and offset variants mutate runtime schema (numericField additional field), so they follow the existing pattern: added to ADDITIONAL_FIELDS_NORMAL_TESTS and run in the additional-fields profile, which has the static field + index.
  • New convex-custom test: offset applied to OR unions.

npm run build, npm run typecheck (src), and the full vitest suite pass: 10 files, 188 passed | 26 skipped (main baseline: 182 passed | 31 skipped).

Note: this touches the same findMany region as #404; whichever merges second will be rebased promptly.

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

@MauruschatM is attempting to deploy a commit to the Convex Team on Vercel.

A member of the Team first needs to authorize it.

helixnebulatech added a commit to helixnebulatech/convex-better-auth that referenced this pull request Oct 8, 2026
findMany threw "offset not supported". Better Auth 1.7.7 passes offset
from the admin plugin's listUsers, which catches the error and returns
{ users: [], total: 0 } for every page after the first, and from the
organization plugin's listMembers, which fails.

The component stays cursor-only: fetch offset + limit rows through the
existing pagination (and the OR union path) and drop the first offset
rows. Re-enables the upstream offset tests; the sortBy variants run in
the additional-fields profile. Ports convex#406.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant