deptyped / prisma-extension-pagination

Prisma Client extension for pagination
https://npmjs.com/prisma-extension-pagination
MIT License
243 stars 18 forks source link

Pagniate not working in prisma 5 #13

Closed dhtmdgkr123 closed 1 year ago

dhtmdgkr123 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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