PrismaP
Prisma8mo ago
3 replies
inhanbyeol

Problems with the Prisma repository pattern?

Is there an issue with the repository pattern I've configured?

/* eslint-disable */
export class CommonRepository<
    Delegate extends {
        create: (...args: any) => any;
        createMany: (...args: any) => any;
        createManyAndReturn: (...args: any) => any;
        ...
    },
> {
    constructor(protected readonly model: any) {
        this.create = model.create.bind(model);
        this.createMany = model.createMany.bind(model);
        this.createManyAndReturn = model.createManyAndReturn.bind(model);
        ...
    }

    public create!: Delegate['create'];
    public createMany!: Delegate['createMany'];
    public createManyAndReturn!: Delegate['createManyAndReturn'];
    ...
}


@Injectable()
export class UserRepository extends CommonRepository<UserDelegate> {
    constructor(private prisma: Database) {
        super(prisma.user);
    }
}
Was this page helpful?