Sequelize extend Model Class in Typescript
Try This
public static init(sequelize) { super.init.call(this,{ id: { type: DataTypes.INTEGER.UNSIGNED, autoIncrement: true, primaryKey: true, }, text: { type: DataTypes.STRING(5000) // extra long length } }, { sequelize: sequelize });}
Was just struggling with a similar problem myself, and this seems to work for me-
class MyModel extends Sequelize.Model { public static initialize(sequelize) { const attributes = { userId: { type: Sequelize.INTEGER, allowNull: false, field: "user_id" }, createdAt: { type: Sequelize.DATE, field: "created_at" } }; return this.init(attributes, { sequelize }); }}
Note that I renamed the static method as "initialize" instead of "init".