'use strict'; 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) { // define association here } } User.init({ // Model attributes are defined here username: { type: DataTypes.STRING, allowNull: false, unique: true, }, email: { type: DataTypes.STRING, allowNull: false, }, firstName: { type: DataTypes.STRING, allowNull: false, }, lastName: { type: DataTypes.STRING, // allowNull defaults to true }, password: { type: DataTypes.STRING, allowNull: false, }, isActive: { type: DataTypes.BOOLEAN, defaultValue: true, }, }, { sequelize, modelName: 'User', tableName: 'users', defaultScope: { attributes: { exclude: ['password'] }, }, scopes: { withPassword: { attributes: { }, } } }); return User; };