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.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server