Skip to content

Add typing for Prisma client with pagination extension #47

Open
@btd1337

Description

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({ limit: 10, page: 1})
}

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?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions