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

Add typing for Prisma client with pagination extension #19

Open
btd1337 opened this issue Nov 21, 2023 · 1 comment
Open

Add typing for Prisma client with pagination extension #19

btd1337 opened this issue Nov 21, 2023 · 1 comment

Comments

@btd1337
Copy link

btd1337 commented Nov 21, 2023

Hi,

When using pagination with NestJs it's necessary to code like this:

// prisma.service.ts

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
    public readonly pagination;

    constructor() {
        super();
        this.pagination = this.$extends(pagination);
      }

      async onModuleInit(): Promise<void> {
        await this.$connect();
      }
}
// in any repository class

findAll(id: string) {
    return this.prismaService.pagination. // no type identification from here on
    
    // expected: return this.prismaService.pagination.any_model.paginate().withPages();
}

But since pagination variable is not typed, when you try to use paginator, autocomplete is not generated anywhere, and also, any schema breakchanges are not detected by prisma.

Is It possible to add pagination types to this library?

Problem reference: #7 (comment)

@btd1337 btd1337 mentioned this issue Nov 21, 2023
@AlexRMU
Copy link

AlexRMU commented Apr 2, 2024

Look at this

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