Cursor Pagination for a List API
Replace offset pagination with a cursor for this list. The list is ordered and new rows arrive at the top while someone pages. LIST Resource: [RESOURCE] Order: [CREATED_AT DESC, ID DESC] Filters: [FILTERS] Page size default and max: [20 / 100] Database: [POSTGRES] DELIVER 1) Why offset breaks on this list (skipped and duplicated rows) in three sentences. 2) The cursor contents: the sort keys, opaque base64, and what happens if a client tampers with it (reject, do not coerce). 3) The SQL: WHERE (created_at, id) < cursor, the index that matches the order and the tenant filter, LIMIT pageSize + 1 so we know there is a next page. 4) The response: items, nextCursor or null. No total count unless I said the product needs it, and if it does, explain why count is a separate query. 5) Tests: empty list, exactly one page, stable order when a new row is inserted during paging, invalid cursor. Do not put raw offsets in the cursor. Do not sort in the application after a limit.
🌟 Example Output / Preview
Prompt Metadata
Primary Use Cases:
- •Legacy code modernization & technical refactoring
- •Full-stack layout generation & component structuring
- •CI/CD workflow automation & unit/E2E testing suites
Associated Tags:
💡 Pro Tips & Advice
1. Use bracketed items: Be sure to fill out all [PLACEHOLDER] elements with specific details before sending the prompt to the AI model.
2. Adjust temperature: For creative tasks, set AI temperature higher (e.g., 0.8), or lower (e.g., 0.2) for strict coding/technical tasks.
🔗 Related AI Prompts
Full SaaS Landing Page Build Spec (SEO + Conversion)
You are a Staff Product Designer + Frontend Engineer + SEO strategist. Build a complete, production-ready marketing landing page f...
SaaS Analytics Dashboard Full Build Spec
You are a Principal Product Designer + Frontend Lead. Design and specify a complete [LIGHT | DARK] analytics dashboard for [PRODUC...
SaaS Admin Panel Dashboard Build Spec
Design a full internal Admin Dashboard for [PRODUCT_NAME] used by [ADMIN_ROLE: support | ops | super-admin]. --- 🎯 CONTEXT Adm...