@earth-app/collegedb
    Preparing search index...

    Function paginate

    • Runs a query across all shards and returns a single page plus the total match count.

      allAllShardsGlobal already merges, filters, sorts, and slices across shards but discards the pre-slice count. paginate keeps that count so list endpoints can return { results, total, page, limit, pages } for a UI in one call instead of issuing a second COUNT query.

      Type Parameters

      • T = Record<string, unknown>

        Type of the result records

      Parameters

      • sql: string

        SQL statement to execute on each shard

      • bindings: any[] = []

        Parameter values to bind to the SQL statement

      • options: PaginateOptions<T> = {}

        Sort/filter options plus page and limit

      Returns Promise<PaginatedResult<T>>

      The requested page and pagination metadata

      1.2.4

      const { results, total, pages } = await paginate<User>(
      'SELECT * FROM users WHERE username LIKE ?',
      ['%ada%'],
      { page: 2, limit: 25, sortBy: 'created_at', sortDirection: 'desc' }
      );