bullpen/backend/models/pitch.model.js

38 lines
867 B
JavaScript

const { Model } = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Pitch extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
Pitch.belongsTo(models.BullpenSession, {
foreignKey: 'bullpenSessionId',
});
Pitch.belongsTo(models.PitchType, {
foreignKey: 'pitchTypeId'
});
}
}
Pitch.init({
pitchTime: {
type: DataTypes.DATE,
allowNull: false
},
aimedArea: {
type: DataTypes.INTEGER,
allowNull: false
},
hitArea: {
type: DataTypes.INTEGER,
allowNull: false
}
}, {
sequelize,
modelName: 'Pitch',
tableName: 'Pitches'
});
return Pitch;
};