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

module.exports = (sequelize) => {
    const QuestionBankReview = sequelize.define('questionbankreview', {
        id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
            primaryKey: true
        },
        description: { type: DataTypes.TEXT, allowNull: true },
        type: { type: DataTypes.TEXT, allowNull: true },
        min_point: { type: DataTypes.TEXT, allowNull: false },
        max_point: { type: DataTypes.INTEGER, allowNull: false },

        questionbank_id: { type: DataTypes.INTEGER, allowNull: false },
    }, {
        tableName: 'questionbankreviews',
    }, {
        freezeTableName: true
    });

    /**
     * Associates the QuestionBankReview model with other models.
     * @param {object} models - The models to associate with.
     * @description
     *   - A QuestionBankReview belongs to one User and one QuestionBank.
     */
    QuestionBankReview.associate = (models) => {
        /**
         * A QuestionBankReview belongs to one QuestionBank.
         * @param {object} models - The models to associate with.
         */
        QuestionBankReview.belongsTo(models.QuestionBank, { foreignKey: 'questionbank_id', as: 'questionbank' });
    };

    return QuestionBankReview;
};

