Kaizen
Browse modulesPersistenceFunctions

Function: offsetPaginate()

function offsetPaginate<T>(
   items: T[], 
   totalCount: number, 
   params?: OffsetPaginationParams
): OffsetPaginatedResult<T>;

Defined in: shared/persistence/offset-pagination.ts:82

Build a paginated result from items and total count.

Type Parameters

Type Parameter
T

Parameters

ParameterType
itemsT[]
totalCountnumber
paramsOffsetPaginationParams

Returns

OffsetPaginatedResult<T>

Example

const [items, totalCount] = await Promise.all([
  prisma.user.findMany({ skip, take }),
  prisma.user.count(),
]);

return offsetPaginate(items, totalCount, { page: 1, pageSize: 20 });

On this page