MathieuM
MathieuM
DTDrizzle Team
Created by MathieuM on 7/12/2023 in #help
Creating an abstract base repository
Hi, I'm trying to create a base repository for my application but can't make it work. Is it even possible? Here is what I'm trying to do:
export class BaseRepository<T> {
constructor (
protected readonly connection: Connection,
protected readonly model: T
) {

}

async findAll(): Promise<InferModel<T>[]> {
const elements = await this.connection.select().from(this.model)
return elements
}
}
export class BaseRepository<T> {
constructor (
protected readonly connection: Connection,
protected readonly model: T
) {

}

async findAll(): Promise<InferModel<T>[]> {
const elements = await this.connection.select().from(this.model)
return elements
}
}
Has anyone ever tested this kind of thing? PS: Here the Connection type is the general db object from drizzle.
1 replies