const { Model, DataTypes } = require('sequelize');

class User extends Model {
    static init(sequelize) {
        super.init({
            name: DataTypes.STRING,
            email: DataTypes.STRING,
            password: DataTypes.STRING
        }, {
            underscored: true,
            sequelize
        })
    };

    static associate(models) {
        this.hasMany(models.Project, {
            foreignKey: 'user_id',
            as: 'projects'
        });
    };
};

module.exports = User;