diff --git a/models/index.js b/models/index.js index 404d906cbb6b8c552343a2970b57cfb218b4098e..46a5d721d6d9d744d1df8400cfd0f83fcb0145d4 100644 --- a/models/index.js +++ b/models/index.js @@ -27,6 +27,8 @@ db.sequelize = sequelize; db.Sequelize = Sequelize; db.Trainer = require('./trainer')(sequelize, Sequelize); +db.Trainer = require('./trainee')(sequelize, Sequelize); + db.Program = require('./program')(sequelize, Sequelize); db.Voucher = require('./voucher')(sequelize, Sequelize); diff --git a/models/trainee.js b/models/trainee.js new file mode 100644 index 0000000000000000000000000000000000000000..c02020371b87386a9aa1ef84437dd2f1407c73e9 --- /dev/null +++ b/models/trainee.js @@ -0,0 +1,73 @@ +module.exports = (sequelize, DataTypes) => { + const trainee = sequelize.define('trainee', { + email: { + type: DataTypes.STRING, + allowNull: false, + unique: true, + validate: { + isEmail: true, + }, + }, + password: { + type: DataTypes.STRING, + allowNull: false, + validate: { + notNull: true, + }, + }, + name: { + type: DataTypes.STRING, + allowNull: false, + validate: { + notNull: true, + }, + }, + phone: { + type: DataTypes.STRING, + allowNull: false, + unique: true, + validate: { + isNumeric: true, + }, + }, + birthDate: { + type: DataTypes.DATEONLY, + allowNull: false, + validate: { + isDate: true, + }, + }, + bio: { + type: DataTypes.TEXT, + allowNull: true, + }, + registerDate: { + type: DataTypes.DATEONLY, + allowNull: false, + validate: { + isDate: true, + }, + }, + expireDate: { + type: DataTypes.DATEONLY, + allowNull: false, + validate: { + isDate: true, + }, + }, + expireCount: { + type: DataTypes.INTEGER, + allowNull: false, + validate: { + min: 0, + }, + }, + + }, { + underscored: true, + timestamps: true, + classMethods: {}, + }); + + return trainee; +};