Skip to main content

map() Method - Pagination Features Documentation

1. Cursor-Based Pagination

Optimized for infinite scroll and large datasets:
  • Advantages:
    • Efficient with large datasets (no offset)
    • Stable with real-time data changes
    • Ideal for consistent sorting

2. Custom Sorting

  • Supported fields: Any existing node property
  • Defaults to insertion order if no field specified

3. Real-Time Mode

  • Callback notifications:
    • added: New matching elements
    • removed: Elements that no longer match query
  • Returns unsubscribe() method to stop updates

4. Result Control Parameters

5. State Persistence

Implementation example:

6. Key Features

  • Bidirectional: Forward/backward pagination
  • Efficient: No full dataset scanning
  • Consistent: Maintains integrity with changing data
  • Configurable: Flexible parameter combinations

7. Typical Workflow

8. Error Handling

  • Invalid cursor: Throws Cursor not found error
  • Invalid sort field: Uses natural insertion order
  • Limit exceeded: Auto-adjusts to max available

9. Return Structure

Real-time mode response:

Complete Usage Example

This implementation follows:
  • Observer Pattern for updates
  • ACID criteria for data consistency
  • Facebook/Twitter-style pagination
  • Performance optimizations for large datasets
Infinite Scroll Example