class Orion::API::CursorPaginator(T)

Overview

Cursor-based pagination (for infinite scroll, real-time data) More efficient for large datasets

Usage: cursor_paginator = Orion::API::CursorPaginator.new( collection: posts, cursor: params["cursor"]?, limit: 25 )

render json: { data: cursor_paginator.items, pagination: cursor_paginator.meta }

Defined in:

orion/api/pagination.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(collection : Array(T), cursor : String | Nil = nil, limit : Int32 = 25) #

Instance Method Detail

def collection : Array(T) #

def collection=(collection : Array(T)) #

def cursor : String | Nil #

def cursor=(cursor : String | Nil) #

def has_more? : Bool #

def items : Array(T) #

Get paginated items


def limit : Int32 #

def limit=(limit : Int32) #

def meta : Hash(String, String | Bool | Int32) #

Get pagination metadata


def next_cursor : String | Nil #