Next.js Discord

Discord Forum

Drizzle orm table type for better and easy inheritance

Unanswered
Weevil parasitoid posted this in #help-forum
Open in Discord
Avatar
Weevil parasitoidOP
In the example below, I have an abstract class with several methods. While redefining these methods for each implementation works, I want to provide default functionality directly in the repository as a static class attribute. This way, I can override the defaults only when needed. However, I’m unsure about the appropriate type for the table attribute. Can someone help me resolve this issue?

export abstract class Repo<TEntity extends { id: string }, TInsert> {

public abstract find(

finder: { id: string },

tx: TConnection

): Promise<Entity<TEntity, TInsert> | null>;

public abstract findOrThrow(

finder: Parameters<typeof this.find>[0],

tx: TConnection

): Promise<Entity<TEntity, TInsert>>;

public abstract create(

inputs: TInsert[],

tx: TConnection

): Promise<Entity<TEntity, TInsert>[]>;

public abstract update(

finder: { id: string },

input: Partial<TEntity>,

tx: TConnection

): Promise<void>;

public abstract softRemove(

finder: { id: string },

tx: TConnection

): Promise<void>;

}

0 Replies