{"size": 909, "ext": "js", "max_stars_repo_path": "app/db/recurso.porcentaje.js", "max_stars_repo_name": "Roberto881/Ticket_1", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/db/recurso.porcentaje.js", "max_issues_repo_name": "Roberto881/Ticket_1", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/db/recurso.porcentaje.js", "max_forks_repo_name": "Roberto881/Ticket_1", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.725, "max_line_length": 68, "alphanum_fraction": 0.5852585259}
const { Sequelize, DataTypes } = require("sequelize");
const sequelize = require('./connexiondb');
const Recurso = require("./recurso");

const RecursoPorcentaje = sequelize.define('recursos_porcentajes', {
    id: {
        type: Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true,
    },
    /*
    id_recurso: {
        type: Sequelize.INTEGER,
        references: {
            model: 'recursos',
            key: 'id'
        },
        allowNull: false        
    },*/
    porcentaje: {
        type: DataTypes.INTEGER,
        allowNull: false,        
    },
}, { 
    timestamps: false
});

let relacion = {
    foreignKey: {
        name: 'id_recurso',
        type: Sequelize.INTEGER,
        allowNull: false
    },
    onDelete: 'CASCADE'
};

Recurso.hasMany(RecursoPorcentaje, relacion);
RecursoPorcentaje.belongsTo(Recurso, relacion);

module.exports = RecursoPorcentaje;