37 lines
685 B
JavaScript
37 lines
685 B
JavaScript
const { DataTypes, Model } = require('sequelize');
|
|
const sequelize = require('../../config/sequelize.conf');
|
|
const Pregunta = require('./Pregunta');
|
|
|
|
class Opcion extends Model {}
|
|
Opcion.init(
|
|
{
|
|
idOpcion: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
allowNull: false,
|
|
unique: true,
|
|
autoIncrement: true,
|
|
},
|
|
opcion: {
|
|
type: DataTypes.STRING(256),
|
|
allowNull: false,
|
|
}
|
|
},
|
|
{
|
|
sequelize,
|
|
modelName: 'Opcion',
|
|
tableName: 'opcion',
|
|
timestamps: false,
|
|
}
|
|
);
|
|
|
|
Opcion.belongsTo(Pregunta, {
|
|
foreignKey: {
|
|
name: 'idPregunta',
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
},
|
|
});
|
|
|
|
module.exports = Opcion;
|