const { Model } = require('sequelize'); module.exports = (sequelize, DataTypes) => { class User extends Model { /** * Helper method for defining associations. * This method is not a part of Sequelize lifecycle. * The `models/index` file will call this method automatically. */ static associate(models) { User.belongsToMany(models.Role, { through: "UserRoles", foreignKey: 'userId', as: 'roles', }); User.belongsTo(models.Auth, { foreignKey: 'authId', as: 'auth' }); } } User.init({ firstName: { type: DataTypes.STRING, allowNull: false }, lastName: { type: DataTypes.STRING, allowNull: false }, dateOfBirth: { type: DataTypes.DATEONLY, allowNull: false }, height: { type: DataTypes.FLOAT }, weight: { type: DataTypes.FLOAT }, gender: { type: DataTypes.ENUM('male', 'female', 'other'), allowNull: false }, handedness: { type: DataTypes.ENUM('left', 'right', 'both'), }, // position: { // type: DataTypes.ENUM // }, // preferredPosition: { // type: DataTypes.ENUM // } }, { sequelize, modelName: 'User', tableName: "Users" }); return User; };