Aller au contenu
login
arrow_backRetour aux issues
a-gondolkodas-orome/durer-aion #191

Add typing to ModellAttributes in sequelize

ecoDébutant good first issue

descriptionDescription

Goal: Make typings script, i.e. if an attribute is missing, or added, then it would raise a type error. In `deletedTeams.ts`, e.g. do the following: ```ts export class DeletedTeamModel extends TeamModel { public deletedAt!: Date; } const teamAttributesWithNoUnique = Object.fromEntries( Object.entries(teamAttributes).map(([key, value]) => [ key, typeof value === "object" && value !== null ? { ...value, unique: false } : value, ]) ) as ModelAttributes; export const deletedTeamAttributes: ModelAttributes = { ...teamAttributesWithNoUnique, deletedAt: { type: DataTypes.DATE, allowNull: false, }, deletedId: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true, }, }; ```
codeOuvre sur GitHub