'use strict'; const { Model, DataTypes } = 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', as: 'bullpenSession' }); Pitch.belongsTo(models.PitchType); } } Pitch.init({ pitchTypeId: { type: DataTypes.INTEGER, allowNull: false, references: { // User belongsTo PitchType 1:1 model: 'PitchTypes', key: 'id' } }, bullpenSessionId: { type: DataTypes.INTEGER, allowNull: false, references: { model: 'BullpenSessions', key: 'id' } }, aimedArea: { type: DataTypes.INTEGER, allowNull: false }, hitArea: { type: DataTypes.INTEGER, allowNull: false } }, { sequelize, modelName: 'Pitch', tableName: 'Pitches' }); return Pitch; };