prisma-pagination
prisma-pagination copied to clipboard
Unknown arg `page`
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,
})
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 } })
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.