prisma-pagination icon indicating copy to clipboard operation
prisma-pagination copied to clipboard

Unknown arg `page`

Open cakctus opened this issue 2 years ago • 1 comments

await paginate(await prisma.cars_model, { where: { cars_generation: { every: { cars_modification: { every: { body_type: { contains: bodyType, }, }, }, }, }, }, include: { cars_generation: { include: { cars_modification: { where: { body_type: { contains: bodyType, }, }, }, }, }, }, take: 10, skip: 0, page: page, }) Screenshot_8

I am trying to implement this code const result = await paginate<User, Prisma.UserFindManyArgs>( prisma.user, { where: { name: { contains: 'Alice' } } orderBy: { id: 'desc', } }, { page: query.page } })

cakctus avatar Dec 30 '22 12:12 cakctus

The paginate function takes three arguments.

first: only the model. (prisma.cars_model) second: findMany options. (only one object containing all the options except skip & take) ({ where, include, ... }) third: The pagination option which are ({ perPage: 10, page: 1})

await paginate(prisma.cars_model, {
  where: {
    cars_generation: {
      every: {
        cars_modification: {
          every: {
            body_type: {
              contains: bodyType,
            },
          },
        },
      },
    },
  },
  include: {
    cars_generation: {
      include: {
        cars_modification: {
          where: {
            body_type: {
              contains: bodyType,
            },
          },
        },
      },
    },
  },
},
{ page, perPage: 10}
)

Also, you don't need to await the first argument, it's just a reference to your model so that the paginate function later invokes .count and .findMany of it.

smohammadhn avatar Mar 07 '24 15:03 smohammadhn