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

Pagniate not working in prisma 5 #13

Closed
dhtmdgkr123 opened this issue Jul 25, 2023 · 3 comments
Closed

Pagniate not working in prisma 5 #13

dhtmdgkr123 opened this issue Jul 25, 2023 · 3 comments

Comments

@dhtmdgkr123
Copy link

dhtmdgkr123 commented Jul 25, 2023

Node Version: v18.16.1
Typescript Version: 5.1.6
Nest Version: 10.1.0
Prisma Client Version: 5.0.0

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "paths": {
      "@/*": ["src/*"]
    },
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": true,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "alwaysStrict": true,
    "exactOptionalPropertyTypes": true,
    "noFallthroughCasesInSwitch": false,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUncheckedIndexedAccess": false,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strictFunctionTypes": true,
    "useUnknownInCatchVariables": false,
    "noImplicitOverride": true
  }
}

Error message:

src/**/user.repository.ts:13:48 - error TS2339: Property 'withPages' does not exist on type 'usermodelsDelegate<DefaultArgs>'.

Reproduce Code

return await this.prismaService.usermodels.withPages({
    limit: 10,
    page: 2,
    includePageCount: true,
});
@deptyped
Copy link
Owner

Hi, before calling withPages you need to call paginate method. The correct code:

return await this.prismaService.usermodels.paginate().withPages({
    limit: 10,
    page: 2,
    includePageCount: true,
});

@dhtmdgkr123
Copy link
Author

Hi, before calling withPages you need to call paginate method. The correct code:

return await this.prismaService.usermodels.paginate().withPages({
    limit: 10,
    page: 2,
    includePageCount: true,
});

xPrisma.ts is below that code

import { PrismaClient } from '@prisma/client';
import { ConfigService } from '@config/config.service';
import pagination from 'prisma-extension-pagination';

const xPrisma = new PrismaClient({
  datasources: {
    db: {
      url: new ConfigService().DB_ENDPOINT,
    },
  },
});

xPrisma.$extends(pagination);

export { xPrisma };
import { xPrisma } from '@/prisma/xPrisma';

    return await xPrisma.usermodels.paginate().withPages({
      limit: 10,
      page: 2,
      includePageCount: true,
    });

and that code occure error

src/**/user.repository.ts:15:37 - error TS2339: Property 'paginate' does not exist on type 'usermodelsDelegate<DefaultArgs>'.

15     return await xPrisma.usermodels.paginate().withPages({
                                       ~~~~~~~~

Envoriment is sameㅠㅠㅠ

@dhtmdgkr123
Copy link
Author

dhtmdgkr123 commented Jul 26, 2023

OMG It working u save my life thank u ~~ 💯

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

2 participants