Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

340
Vistas
How to import Prisma model in prisma-offset-pagination

I am using a package prisma-offset-pagination to apply pagination. For this I have to use Prisma Model in my code, how is that possible: Check line: 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,
});

I tried it using the code below but it didn't work and throws an 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 Respuestas
Responde la pregunta

0

This is how prismaOffsetPagination function looks like:

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,
    },
  });

As you can see, model.name.toLowerCase() suggests that model is an object with a name property: model:{name:string}

Based on this, for me it worked passing the name of the model inside the object, as follows:

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda