Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard to understand how to use this package #6

Open
romgrk-comparative opened this issue Oct 18, 2021 · 4 comments
Open

Hard to understand how to use this package #6

romgrk-comparative opened this issue Oct 18, 2021 · 4 comments

Comments

@romgrk-comparative
Copy link

Hi,

I've been trying to make this package work for an hour but the documentation for how to actually use this package is unclear. Could you add a runnable code example or tests that would show how to use it?

In particular, I couldn't understand where the model field must come from.

Thanks.

@lvcax
Copy link

lvcax commented Dec 29, 2021

I'm have the same problem :/

@phenomenal-hardy
Copy link

phenomenal-hardy commented May 2, 2022

this is what im doing but i still get an error


const { PrismaClient } = require('@prisma/client');
const { prismaOffsetPagination } = require('prisma-offset-pagination');
const prisma = new PrismaClient()

    const result = prismaOffsetPagination({
        model: prisma.Product,
        //cursor: <cursor>,
        size: 5, // Receive the number of row in the page
        buttonNum: 1,
        orderBy: 'id',
        orderDirection: 'asc',
        prisma: prisma,
    });

Cannot read properties of undefined (reading 'toLowerCase')

My 'model' is not being read

@ken1800
Copy link

ken1800 commented May 31, 2022

Hi, this refers to the model of the class you'd want to access.

From your example, we'd have something like this:
`
// This will probably come from your .entity.ts

export class Product {
id: string;
name: string
}

const { PrismaClient } = require('@prisma/client');
const { prismaOffsetPagination } = require('prisma-offset-pagination');
const prisma = new PrismaClient()

const result = prismaOffsetPagination({
    model: Product       <= This will be the model type
    //cursor: <cursor>,
    size: 5, // Receive the number of row in the page
    buttonNum: 1,
    orderBy: 'id',
    orderDirection: 'asc',
    prisma: prisma,
});`

@joetech
Copy link

joetech commented Jun 21, 2022

I ran into this problem as well. For mine to work, I had to reference the model name like this.
model: {name: 'user'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants