Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate extends Model into @Table decorator #1744

Open
liv1n9 opened this issue Apr 11, 2025 · 0 comments
Open

Integrate extends Model into @Table decorator #1744

liv1n9 opened this issue Apr 11, 2025 · 0 comments

Comments

@liv1n9
Copy link

liv1n9 commented Apr 11, 2025

I'm using sequelize-typescript in my project. To define a model, I create two separate classes: an entity class and a model class:

// Entity class
class User {
  username: string;
  fullName: string;
}

// Model class
@Table({ tableName: "user" })
class UserModel extends Model implements User {
  @Column
  username: string;
  
  @Column
  fullName: string;
}

I do this in order to separate my entitiy's interfaces from sequelize model's interface (using in repository pattern). It's a bit inconvinient since I have to do the declaring job twice.

So can we integrate extends Model to @Table decorator? So that I only have to define everything in Entity classes. For example:

@Table({ tableName: "user", extends: false })
class User {
  @Column
  username: string;
  
  @Column
  fullName: string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant