deptyped / prisma-extension-pagination

Prisma Client extension for pagination
https://npmjs.com/prisma-extension-pagination
MIT License
243 stars 18 forks source link

Suggestions for pagination object #24

Open xtrandom opened 8 months ago

xtrandom commented 8 months ago

First of all, very nice pagination implementation!

Would it be possible to add pageSize / perPage property to the paginated response? Also, in line with currentPage, previousPage, nextPage variables, maybe pageCount can be renamed to lastPage, or in line with totalCount -> totalPages?

// Suggested:
{
  pageSize: 10, // <- Added
  currentPage: 2,
  isFirstPage: false,
  isLastPage: false,
  previousPage: 1,
  nextPage: 3,
  lastPage: 10, // or totalPages <- Updated
  totalCount: 100
}

lastPage could be calculated using `Math.ceil(total / perPage)`

Also, perhaps the return format can be updated like so:

// Current:
[
    [
        item1,
        item2,
        ...
    ],
    {
        // pagination meta
    }
]

// Suggested:
{
    "data": [
        item1,
        item2,
        ...
    ],
    "meta": {
        // pagination meta
    }
}

Thank you!