38665-vm/backend/src/db/models/team_season_stats.js
2026-02-21 10:22:00 +00:00

120 lines
1.7 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 team_season_stats = sequelize.define(
'team_season_stats',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
yellow_cards_per_game: {
type: DataTypes.DECIMAL,
},
matches_played: {
type: DataTypes.INTEGER,
},
last_updated_at: {
type: DataTypes.DATE,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
team_season_stats.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.team_season_stats.belongsTo(db.teams, {
as: 'team',
foreignKey: {
name: 'teamId',
},
constraints: false,
});
db.team_season_stats.belongsTo(db.seasons, {
as: 'season',
foreignKey: {
name: 'seasonId',
},
constraints: false,
});
db.team_season_stats.belongsTo(db.data_providers, {
as: 'source_provider',
foreignKey: {
name: 'source_providerId',
},
constraints: false,
});
db.team_season_stats.belongsTo(db.users, {
as: 'createdBy',
});
db.team_season_stats.belongsTo(db.users, {
as: 'updatedBy',
});
};
return team_season_stats;
};