131 lines
2.0 KiB
JavaScript
131 lines
2.0 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const professor_teaching_histories = sequelize.define(
|
|
'professor_teaching_histories',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
hours_assigned: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
times_taught_in_semester: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
taught_last_semester: {
|
|
type: DataTypes.BOOLEAN,
|
|
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
notes: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
professor_teaching_histories.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.professor_teaching_histories.belongsTo(db.professors, {
|
|
as: 'professor',
|
|
foreignKey: {
|
|
name: 'professorId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.professor_teaching_histories.belongsTo(db.subjects, {
|
|
as: 'subject',
|
|
foreignKey: {
|
|
name: 'subjectId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.professor_teaching_histories.belongsTo(db.semesters, {
|
|
as: 'semester',
|
|
foreignKey: {
|
|
name: 'semesterId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.professor_teaching_histories.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.professor_teaching_histories.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return professor_teaching_histories;
|
|
};
|
|
|
|
|