Created
March 5, 2020 18:38
-
-
Save mvegap/f39824b9fa15cf3cfa3c2107b82f76b1 to your computer and use it in GitHub Desktop.
model-tutor.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (sequelize, DataTypes) => { | |
const Tutor = sequelize.define('Tutor', { | |
id: { | |
allowNull: false, | |
autoIncrement: true, | |
primaryKey: true, | |
type: DataTypes.INTEGER, | |
}, | |
colaboradorId: { | |
allowNull: false, | |
type: DataTypes.INTEGER, | |
}, | |
universidadId: { | |
allowNull: false, | |
type: DataTypes.INTEGER, | |
}, | |
cicloUniversidadId: { | |
allowNull: false, | |
type: DataTypes.INTEGER, | |
}, | |
estiloAprendizajeId: { | |
allowNull: true, | |
type: DataTypes.INTEGER, | |
}, | |
interesId: { | |
allowNull: true, | |
type: DataTypes.INTEGER, | |
}, | |
tipoPersonalidadId: { | |
allowNull: true, | |
type: DataTypes.INTEGER, | |
}, | |
actualizarDatos: { | |
allowNull: false, | |
type: DataTypes.ENUM('S', 'N'), | |
defaultValue: 'S', | |
}, | |
donacionMensual: { | |
allowNull: true, | |
type: DataTypes.TINYINT, | |
}, | |
montoDonacion: { | |
allowNull: true, | |
type: DataTypes.INTEGER, | |
}, | |
}, { | |
timestamps: true, | |
paranoid: true, | |
version: true, | |
freezeTableName: true, | |
}); | |
Tutor.associate = function (models) { | |
Tutor.belongsTo(models.Colaborador, { | |
as: 'Colaborador', | |
foreignKey: 'colaboradorId', | |
targetKey: 'id', | |
}); | |
Tutor.belongsTo(models.Universidad, { | |
as: 'Universidad', | |
foreignKey: 'universidadId', | |
targetKey: 'id', | |
}); | |
Tutor.belongsTo(models.EstiloAprendizaje, { | |
as: 'EstiloAprendizaje', | |
foreignKey: 'estiloAprendizajeId', | |
targetKey: 'id', | |
}); | |
Tutor.belongsTo(models.Interes, { | |
as: 'Interes', | |
foreignKey: 'interesId', | |
targetKey: 'id', | |
}); | |
Tutor.belongsTo(models.TipoPersonalidad, { | |
as: 'TipoPersonalidad', | |
foreignKey: 'tipoPersonalidadId', | |
targetKey: 'id', | |
}); | |
}; | |
return Tutor; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try This
module.exports = (sequelize, DataTypes) => { const Tutor = sequelize.define('Tutor', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: DataTypes.INTEGER, }, colaboradorId: { allowNull: false, type: DataTypes.INTEGER, }, universidadId: { allowNull: false, type: DataTypes.INTEGER, }, cicloUniversidadId: { allowNull: false, type: DataTypes.INTEGER, }, estiloAprendizajeId: { allowNull: true, type: DataTypes.INTEGER, }, interesId: { allowNull: true, type: DataTypes.INTEGER, }, tipoPersonalidadId: { allowNull: true, type: DataTypes.INTEGER, }, actualizarDatos: { allowNull: false, type: DataTypes.ENUM('S', 'N'), defaultValue: 'S', }, donacionMensual: { allowNull: true, type: DataTypes.TINYINT, }, montoDonacion: { allowNull: true, type: DataTypes.INTEGER, }, }, { timestamps: true, paranoid: true, version: true, freezeTableName: true, }); Tutor.associate = function (models) { Tutor.belongsTo(models.Colaborador); Tutor.belongsTo(models.Universidad); Tutor.belongsTo(models.EstiloAprendizaje); Tutor.belongsTo(models.Interes); Tutor.belongsTo(models.TipoPersonalidad); }; return Tutor; };