Replace Offset With Cursor Pagination
Design cursor pagination that preserves stable ordering as records are inserted or deleted.
GET /payouts?offset=200&limit=50 duplicates and skips rows when new payouts are inserted while an admin is paging through failures. Use deterministic ordering plus opaque continuation tokens instead of client-computed offsets. Offset pagination works in demos because fixtures do not move. In production, inserts and deletes shift row positions between requests, so page numbers describe a moving target. Choose order Sort by created_at desc, id desc so records with equal timestamps still have a deterministic position. A cursor needs a total order, not just a friendly display sort. Fetch boundary Request limit + 1 rows after the decoded cursor boundary. The extra…
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in