Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

341
Views
Cómo importar el modelo Prisma en prisma-offset-pagination

Estoy usando un paquete prisma-offset-pagination para aplicar la paginación. Para esto, tengo que usar Prisma Model en mi código, ¿cómo es eso posible? Verifique la línea: 02

 const result = prismaOffsetPagination({ model: user, // How to access prisma model like in this example. cursor: <cursor>, size: 5, buttonNum: 7, orderBy: 'id', orderDirection: 'desc', prisma: prisma, });

Lo probé usando el código a continuación, pero no funcionó y arroja un error: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toLowerCase' of undefined at prismaOffsetPagination

 import pClient from '@prisma/client' const { PrismaClient } = pClient const { prisma } = new PrismaClient() const result = prismaOffsetPagination({ model: prisma.user, cursor: 2, size: 5, buttonNum: 3, orderBy: 'id', orderDirection: 'desc', })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Así es como se ve la función prismaOffsetPagination:

 export async function prismaOffsetPagination({ model, cursor, size, buttonNum, orderBy, orderDirection, include, where, prisma, }: Props<typeof model>): Promise<PaginationType> { // totalCount const prismaModel = prisma[model.name.toLowerCase()]; const totalCount = await prismaModel.count({ where: { ...where, }, });

Como puede ver, model.name.toLowerCase() sugiere que model es un objeto con una propiedad de nombre: model:{name:string}

Basado en esto, para mí funcionó pasando el nombre del modelo dentro del objeto, de la siguiente manera:

 const result = prismaOffsetPagination({ model: {name: 'user'} cursor: <cursor>, size: 5, buttonNum: 7, orderBy: 'id', orderDirection: 'desc', prisma: prisma, });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!