Files
bowlingManager/backend/models/EventScore.js
T
2025-04-24 12:01:51 +09:00

62 lines
1.2 KiB
JavaScript

const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const EventScore = sequelize.define('EventScore', {
id: {
type: DataTypes.INTEGER.UNSIGNED,
primaryKey: true,
autoIncrement: true
},
eventId: {
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
references: {
model: 'Events',
key: 'id'
}
},
participantId: {
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
references: {
model: 'EventParticipants',
key: 'id'
}
},
teamNumber: {
type: DataTypes.INTEGER.UNSIGNED,
allowNull: true,
},
gameNumber: {
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false
},
score: {
type: DataTypes.INTEGER,
allowNull: false
},
handicap: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0
},
totalScore: {
type: DataTypes.INTEGER,
allowNull: false
}
}, {
tableName: 'EventScores',
timestamps: true
});
EventScore.associate = (models) => {
EventScore.belongsTo(models.Event, {
foreignKey: 'eventId'
});
EventScore.belongsTo(models.EventParticipant, {
foreignKey: 'participantId'
});
};
module.exports = EventScore;