const { Model } = require('sequelize'); module.exports = (sequelize, DataTypes) => { class User extends Model { /** * Helper method for defining associations. * This method is not a part of the 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 }, }, { sequelize, modelName: 'User', tableName: "Users" }); return User; };