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
| Parameter | Type |
|---|---|
items | T[] |
totalCount | number |
params | OffsetPaginationParams |
Returns
Example
const [items, totalCount] = await Promise.all([
prisma.user.findMany({ skip, take }),
prisma.user.count(),
]);
return offsetPaginate(items, totalCount, { page: 1, pageSize: 20 });