64 lines
1.3 KiB
JavaScript
64 lines
1.3 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
const AverageCache = sequelize.define('AverageCache', {
|
|
id: {
|
|
type: DataTypes.BIGINT.UNSIGNED,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
comment: '캐시 고유값'
|
|
},
|
|
memberId: {
|
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
allowNull: false,
|
|
comment: '회원 ID'
|
|
},
|
|
clubId: {
|
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
allowNull: false,
|
|
comment: '클럽 ID'
|
|
},
|
|
startDate: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
comment: '계산 시작일'
|
|
},
|
|
endDate: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
comment: '계산 종료일'
|
|
},
|
|
average: {
|
|
type: DataTypes.FLOAT,
|
|
allowNull: false,
|
|
comment: '에버리지'
|
|
},
|
|
games: {
|
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
allowNull: false,
|
|
comment: '경기수'
|
|
},
|
|
totalScore: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
comment: '총점'
|
|
},
|
|
expiredAt: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
comment: '만료 시각(TTL)'
|
|
}
|
|
}, {
|
|
tableName: 'AverageCache',
|
|
comment: '회원별 기간별 에버리지 캐시 테이블',
|
|
timestamps: true,
|
|
indexes: [
|
|
{
|
|
unique: true,
|
|
fields: ['memberId', 'clubId', 'startDate', 'endDate']
|
|
}
|
|
]
|
|
});
|
|
|
|
module.exports = AverageCache;
|