0.0.3 • Published 2 years ago

prisma-offset-paginate v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Prisma Offset Paginate

Helper function for Prisma offset paginate with Typescript support.

Version License

Installation

npm i prisma-offset-paginate

Usage

import paginate from 'prisma-offset-paginate'

// Auto detects type base on model you send to it.
// So args and result will be typed and autocompleted.
const result = await paginate(
  prisma.user,
    {
      where: {
        name: {
          contains: 'Alice'
        }
      }
      orderBy: {
        id: 'desc',
      }
    }, 
    { page: 1 }
);

/* Result structure:
{
  data: User[]
  meta: {
    pagination: {
      page: number
      pageSize: number
      pageCount: number
      total: number
    },
  },
}
*/

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago