import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';

class Knowledge extends Model { }

Knowledge.init({
    productId: {
        type: DataTypes.INTEGER,
        allowNull: false},
    characterId: {
        type: DataTypes.INTEGER,
        allowNull: false},
    knowledge: {
        type: DataTypes.INTEGER,
        allowNull: false,
        defaultValue: 0}
}, {
    sequelize,
    modelName: 'Knowledge',
    tableName: 'knowledge',
    schema: 'falukant_data',
    timestamps: false,
    underscored: true,
    hooks: {
        beforeCreate: (knowledge) => {
            knowledge.knowledge = Math.floor(Math.random() * 61) + 20;
        }
    }
});

export default Knowledge;
