sequelize-typescript
sequelize-typescript copied to clipboard
Possibility to extend one model entity from another
Issue
Versions
- sequelize: ^6.5.0
- sequelize-typescript: ^2.1.0
- typescript: ^4.0.5
Issue type
- [ ] bug report
- [x] feature request
Actual behavior
Expected behavior
I need feature extending one Model from another. For purpose to avoid repetitions of entity basic attributes. See related code.
Steps to reproduce
Related code
// Base Entity
export class BaseEntity {
@Column()
fieldOne: number;
@Column()
fieldTwo: string;
}
// Child entity with three fields
export class Provider extends Model<BaseEntity, ProviderCreationAttrs> {
@Column({
type: DataType.STRING,
unique: true,
allowNull: false,
})
fieldThree: boolean;
}
Having the exact same requirement and i'm also using sequelize and sequelize-typescript
This is something we plan on improving in Sequelize itself (See 'Model Inheritance' here https://github.com/sequelize/sequelize/issues/14298)